[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Collapse]PDF Viewer
   [Expand]Getting Started
    Coordinate Systems
   [Expand]Navigation
   [Expand]Access and Edit Document Content
   [Expand]Interactivity
    Deployment
   [Collapse]Examples
    [Expand]Getting Started
    [Expand]Interactive Form
    [Expand]Text Markup Annotations
    [Collapse]Interactivity
      How to: Determine the Page Number of a Clicked PDF Page
      How to: Determine the PDF Content Type Corresponding to a Specific Point in a Document
      How to: Find Text Using a Keyboard Shortcut
      How to: Custom Draw in the PDF Viewer
    [Expand]Customization
    [Expand]Printing
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Custom Draw in the PDF Viewer

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T328482.

The PDF Viewer can draw graphics in the PDF document in the Control.Paint event handler.

In this example, the filled rectangle is drawn at any document space when you hold down the left mouse button and move it.

The PDF Viewer gets the mouse position relative to the document by calling the PdfViewer.GetDocumentPosition method in the MouseDown (when the left mouse is pressed), and MouseMove event handlers (when the mouse is moving).

To draw a filled rectangle, the RectangleF.FromLTRB method is called in the Paint event handler. The start and end client points are obtained using the document position in the PdfViewer.GetClientPoint method.

This example also shows how to draw a rectangle using the Graphics.FillRectangle method.

Is this topic helpful?​​​​​​​