
Syncfusion Wpf Pdf Viewer
- 1 installs
- 1 repo stars
- Updated July 6, 2026
- syncfusion/pdf-viewer-sdk-skills
Generates WPF C# and XAML code to embed and customize the Syncfusion PdfViewer with navigation, zooming, text selection, search, annotations, and toolbar customization.
About
Generates C# and XAML code for the Syncfusion WPF PdfViewer covering display, navigation, search, annotations, and event handling. A developer uses it when building PDF viewing solutions in WPF desktop apps.
- Requires .NET Framework 4.5+ or .NET Core/NET 8+ with Syncfusion.WPF.PdfViewer
- Generates copy-pasteable C# and XAML code
Syncfusion Wpf Pdf Viewer by the numbers
- 1 all-time installs (skills.sh)
- Ranked #121 of 153 .NET & C# skills by installs in the Skillselion catalog
- Data as of Jul 8, 2026 (Skillselion catalog sync)
npx skills add https://github.com/syncfusion/pdf-viewer-sdk-skills --skill syncfusion-wpf-pdf-viewerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 1 |
| Last updated | July 6, 2026 |
| Repository | syncfusion/pdf-viewer-sdk-skills ↗ |
What it does
Generates WPF C# and XAML code to embed and customize the Syncfusion PdfViewer with navigation, zooming, text selection, search, annotations, and toolbar customization.
Files
Syncfusion WPF PDFViewer – UI Sample Generator
Generate C# Code for the User's Project (default)
Trigger keywords: "how to", "code sample", "show me", "example", "snippet", "integrate", "wpf PdfViewer", "create sample".
Purpose: Generate clean, ready-to-use C# and XAML code snippets that users can directly insert into their WPF applications when working with the Syncfusion WPF PdfViewer control.
Workflow: 1. Build the C# code using snippets provided in the references/*.md files. 2. Before generating the sample, ask the user whether the code should be inserted into an existing XAML file in their WPF project or created as a new WPF project application. 3. If the user chooses to create a new WPF project, ask them which target framework they want to use:
- .NET Framework (e.g. 4.6, 4.7, 4.8) — uses
Syncfusion.PdfViewer.WPFand targets classic .NET Framework. - .NET Core / .NET (e.g., .NET 8, .NET 10) — uses
Syncfusion.PdfViewer.WPFwith<TargetFramework>net8.0-windows</TargetFramework>(or the selected version). - Based on the user's choice, generate the
.csprojfile with the correct<TargetFramework>value, and tailor any framework-specific code (e.g., namespace imports, NuGet package versions, startup code) accordingly.
4. XAML generation rules — MANDATORY: analyze the reference files BEFORE writing any XAML:
⚠️ STRICT RULE — NO EXCEPTIONS:
Open and read the relevant references/*.md file(s) for the requested feature before producing any XAML.Ask yourself: "Does the reference file contain any XAML markup for this feature?"
- YES → XAML exists in reference → include only those exact XAML elements shown in the snippet.
- NO → reference is C# only →MainWindow.xamlMUST contain only<syncfusion:PdfViewerControl>inside a<Grid>. Stop. Do not add anything else.
Checklist to run before every XAML output:
- [ ] I have opened the relevant
references/*.mdfile. - [ ] I have confirmed whether it contains XAML or is C#-only.
- [ ] If C#-only: my XAML contains nothing beyond
<syncfusion:PdfViewerControl x:Name="pdfViewer"/>inside<Grid>. - [ ] If XAML exists in reference: I am copying only those elements — not inventing new ones.
Forbidden (when reference has no XAML): <Button>, <ComboBox>, <Slider>, <StackPanel>, <TextBlock>, <Grid.RowDefinitions>, or any UI element that does not appear verbatim in the reference snippet.
Known C#-only features (no XAML must be generated):
- Ink / shape / stamp / text / highlight annotations (
annotation.md) — all settings are C# only. - Magnifying / zoom level (
magnifying.md) — C# only. - Interaction mode (
interaction-mode.md) — C# only. - Text selection (
text-selection.md) — C# only. - PDF layers (
pdf-layers.md) — C# only. - Redaction (
redaction.md) — C# only. - Print (
print.md) — C# only. - Export image (
export-image.md) — C# only. - Saving PDF (
saving-pdf-files.md) — C# only.
Known features that DO require XAML (sourced from references):
- Commands (
commands.md): navigation/zoom/annotation/undo/redo/print/unload buttons useCommand="{Binding ElementName=..., Path=...}". - Toolbar items (
toolbar-items.md): classic style requiresStyle="{StaticResource SyncfusionPdfViewerCustomControlStyle}"on<syncfusion:PdfViewerControl>.
All XAML additions must be placed inside the same <Grid> that hosts <syncfusion:PdfViewerControl>, using a <StackPanel> or <Grid> sub-layout only when the reference snippet implies it. 5. Add only the APIs required to satisfy the user's requested functionality. Do not include optional APIs, additional. 6. C# language version compatibility: When the target framework is .NET Framework (e.g., 4.6, 4.7, 4.8), the default C# language version is 7.3. The generated C# code MUST NOT use any C# 8.0+ language features. Specifically, do NOT use:
- Switch expressions (
x switch { ... }) - Nullable reference types (
string?,#nullable enable,object?) - Default interface implementations
- Ranges and indices (
^1,1..^1) ??=null-coalescing assignment
Use if/else or traditional switch statements instead of switch expressions. Use regular null checks (if (x != null)) instead of nullable reference type syntax. ---
Code References
All templates and operation snippets live in references/*.md. Each file is a focused snippet or template the agent will combine when generating samples.
| File | Purpose |
|---|---|
| Load-sample.md | Load and unload PDFs using file paths, streams, or PdfLoadedDocument (encrypted or not); support async loading, MVVM binding, password handling, loading indicator customization, and theme application. |
| navigation.md | Navigate PDF pages using index‑ or number‑based APIs; retrieve page state information; scroll programmatically; manage thumbnails and bookmarks; and handle hyperlink navigation events. |
| annotation.md | Enable, customize, and manage all annotation types; handle annotation events; programmatically select, hide, lock, or delete annotations; control comments panel, authorship, hyperlinks, and selection visuals. |
| pdf-rendering.md | Configure the PDF rendering engine by switching between PDFium and SfPdf and setting the required ReferencePath. |
| text-extraction-engine.md | Select the text extraction engine (PDFium or SfPdf) to control text extraction behavior. |
| print.md | Print PDFs with silent or dialog options; configure printers, page size, scaling, orientation, page range, paper source, and document name; and handle print lifecycle events. |
| export-image.md | Export PDF pages or page ranges as images (JPG, PNG, TIFF, BMP) with control over size, DPI, aspect ratio, and transparency. |
| import-export-annotations.md | Import and export annotations using FDF or XFDF formats. |
| extract-text-from-pdf.md | Extract text content and bounding information from pages or the entire document. |
| form-filling.md | Handle AcroForm fields: manage form events, show or hide icons, import/export form data, and add or edit form fields programmatically. |
| pdf-layers.md | Access and manage PDF layers by toggling visibility, enabling or disabling layers, and controlling the Layers pane UI. |
| redaction.md | Apply redactions by marking regions, customizing appearance, and handling redaction events. |
| pdf-coordinates.md | Convert between coordinate systems, retrieve scroll offsets, and zoom into specific page regions. |
| organize-pages.md | Rotate, reorder, and remove pages using page organizer features. |
| handwritten-signature.md | Capture handwritten signatures, customize appearance, handle signature events, and flatten signatures on save. |
| interaction-mode.md | Switch viewer interaction modes such as text selection, panning, and marquee zoom using cursor settings. |
| pdf-pages.md | Customize page appearance, handle page interaction events, and convert pixel coordinates to PDF points. |
| saving-pdf-files.md | Save edited PDFs, detect unsaved changes, cancel save operations, handle save events, and prompt before closing with pending edits. |
| magnifying.md | Control zoom behavior including zoom levels, fit modes, limits, zoom-to-rectangle, toolbar visibility, and zoom change events. |
| searching-text.md | Search and highlight text, navigate results, retrieve match bounds and text details, support multi-line search, and control search UI and availability. |
| text-selection.md | Detect text selection completion, retrieve selected text and bounds, customize highlight color, enable or disable selection, and clear selections programmatically. |
| localization.md | Localize the PDF Viewer UI using .resx resources and culture settings. |
| customize-contextmenu.md | Customize context menus by adding, removing, hiding items, and handling menu click events. |
| commands.md | Use and bind built‑in WPF commands for navigation, zoom, search, annotations, undo/redo, printing, saving, and unloading documents. |
| toolbar-items.md | Customize viewer UI by showing or hiding toolbars, panels, buttons, menus, notification bars, and switching toolbar styles. |
---
Prerequisites
1. Development Environment: Visual Studio 2022 or Visual Studio Insider 2026 (recommended for .NET 10). 2. NET Framework 4.5+ or .NET Core/.NET 8+ with WPF support. 3. Syncfusion WPF NuGet Packages: Syncfusion.PdfViewer.WPF
Theme NuGet Packages
To apply a built-in theme to the WPF PdfViewerControl using SfSkinManager, install the NuGet package that matches the desired theme:
| Theme Name | Required NuGet Package |
|---|---|
FluentLight | Syncfusion.Themes.FluentLight.WPF |
FluentDark | Syncfusion.Themes.FluentDark.WPF |
MaterialLight | Syncfusion.Themes.MaterialLight.WPF |
MaterialDark | Syncfusion.Themes.MaterialDark.WPF |
MaterialLight3 | Syncfusion.Themes.MaterialLight3.WPF |
MaterialDark3 | Syncfusion.Themes.MaterialDark3.WPF |
Office2019Colorful | Syncfusion.Themes.Office2019Colorful.WPF |
Office2019Black | Syncfusion.Themes.Office2019Black.WPF |
Office2019White | Syncfusion.Themes.Office2019White.WPF |
Office2019DarkGray | Syncfusion.Themes.Office2019DarkGray.WPF |
Windows11Light | Syncfusion.Themes.Windows11Light.WPF |
Windows11Dark | Syncfusion.Themes.Windows11Dark.WPF |
Note: Install only the NuGet package corresponding to the theme the user wants to apply. Theme support requires Syncfusion.SfSkinManager.WPF, which is included as a dependency of the theme packages.>
Refer to: Apply theme using SfSkinManager | WPF PdfViewer Theme
Documentations
Syncfusion WPF PDF Viewer (PdfViewerControl) Skill
Overview
Display, load, and interact with PDF documents in WPF using Syncfusion's PdfViewerControl — concise, paste-ready XAML/C# examples for loading PDFs, annotations, text search, toolbar customization, printing, form filling, and many other PDF tasks.
See [SKILL.md](SKILL.md) for the full intent-routing guide and rules.
---
Key Capabilities
- PDF Loading & Display: load from file path, stream, or
PdfLoadedDocument; support for encrypted PDFs and MVVM binding viaItemSource. - Annotations: ink, shapes (line, rectangle, circle, arrow, polygon, polyline), stamp, sticky note, free text, text callout, highlight, underline, strikethrough, squiggly, and file link annotations.
- Navigation & Interaction: page navigation, thumbnails, bookmarks, hyperlinks, zoom modes, and cursor interaction modes (Selection, Panning, Marquee Zoom).
- Text Operations: text search with highlight, text selection, and full text extraction with bounds.
- Forms & Signatures: AcroForm field management, FDF import/export, and handwritten signature support.
- Toolbar & UI Customization: show/hide toolbar items, disable specific buttons, customize context menus, and apply localization.
- Document Processing: print (silent and interactive), save PDF, export pages as images, import/export annotations (FDF/XFDF), page organize (rotate, reorder, remove), and redaction.
- Advanced Features: PDF layers, PDF coordinates/scroll offsets, rendering engine switching (PDFium/SfPdf), and text extraction engine switching.
---
Getting Started
How to Integrate the Skill
Step 1: Checkout and copy the required skill
Clone or download the PDF-Viewer-SDK-Skills repository and copy the wpf-pdfviewer-code-generator skill from the skills/ directory.
Step 2: Install the skill
Place the copied skill folder in your workspace following this structure:
your-workspace/
├── .github/skills/ # or .claude/skills/ or .codestudio/skills/
│ └── wpf-pdfviewer-code-generator/
│ └── SKILL.md
├── your-project-files...
└── MainWindow.xamlStep 3: Verify and manage your skills
Type /skills in the GitHub Copilot or Code Studio chat to quickly access the Configure Skills menu and manage your installed skills.
Step 4: Use the skill in VS Code / Code Studio
There are two ways to use the skill:
1. Slash commands – Type / in the GitHub Copilot chat to see available skills. For example:
/wpf-pdfviewer How do I load an encrypted PDF?2. Automatic loading – Simply describe your task naturally, and the AI Agent automatically loads the relevant skill:
Create a WPF window with PdfViewerControl that highlights text and exports annotations to XFDFWhen the wpf-pdfviewer skill is loaded, the AI Agent provides focused XAML/C# snippets and commands for PdfViewerControl.
---
Prerequisites
1. Visual Studio 2022 or later (WPF workload installed) 2. .NET Framework 4.5+ or .NET Core / .NET 8+ with WPF support 3. Syncfusion License — register your key inside the MainWindow constructor:
SyncfusionLicenseProvider.RegisterLicense("Your-License-Key");Free license: Syncfusion Community License
NuGet Package
dotnet add package Syncfusion.PdfViewer.WPF---
Example Prompts
Loading & Display
- "Show me how to load a PDF from a file path using
PdfViewerControl." - "Generate code to load a password-protected PDF and suppress the built-in password dialog."
- "Provide a MVVM example where
ItemSourceis bound to a ViewModel property."
Annotations
- "Generate C# to enable ink annotation mode with a green color and 5px thickness."
- "Show me how to add a custom stamp image programmatically at a specific page position."
- "Provide code to listen to
TextMarkupAnnotationChangedevents for highlight, underline, and strikethrough." - "How do I lock all annotations so they can't be edited or deleted?"
Navigation & Zoom
- "Show code to navigate to a specific page and zoom to 150%."
- "How do I switch the cursor to Panning mode programmatically?"
- "Generate code to handle bookmark navigation events."
Text Search & Selection
- "Show me how to search for text in the PDF and highlight all matches."
- "Provide code to retrieve the selected text and its bounds from
PdfViewerControl."
Toolbar & UI Customization
- "How do I hide the default toolbar and scrollbar?"
- "Show me how to collapse a specific toolbar button like the text search button."
- "Generate code to add a custom item to the PdfViewer context menu."
Printing & Saving
- "Show me how to silently print the PDF to a specific printer."
- "Generate code to save the PDF to a file path and handle the save completed event."
Forms & Signatures
- "How do I import form data from an FDF file into the viewer?"
- "Show me how to enable handwritten signature mode and flatten signatures on save."
Export & Extraction
- "Generate code to export page 2 as a PNG image."
- "Show me how to extract all text and bounds from every page of the loaded PDF."
Advanced
- "How do I switch the rendering engine to PDFium?"
- "Show me how to mark a region for redaction and apply it."
- "Provide code to rotate and reorder pages using the page organizer."
---
Reference Files
All code snippets used by the AI Agent are organized in the references/ folder:
| File | Purpose |
|---|---|
Load-sample.md | Load PDFs via stream or file path (encrypted and normal); unload document; customize loading indicator color and message. |
navigation.md | Page navigation (including GoToPageAtIndex), page count, current page index, thumbnail panel, bookmark navigation, and hyperlink events. |
annotation.md | Add and control annotations (ink, shapes, stamp, text, highlights, etc.); disable annotation selection; set current user; customize annotation selector colors. |
pdf-rendering.md | Switch rendering engine (PDFium/SfPdf) and set ReferencePath. |
text-extraction-engine.md | Switch text extraction engine (PDFium/SfPdf). |
print.md | Print settings, silent print, paper source, and print events. |
export-image.md | Export pages as images (JPG, PNG, TIFF, BMP) using ExportAsImage. |
import-export-annotations.md | Import/export annotations in FDF or XFDF format using ImportAnnotations and ExportAnnotations. |
extract-text-from-pdf.md | Extract text and bounds from pages or full document. |
form-filling.md | Form field events, FDF import/export, and AcroForm field management. |
pdf-layers.md | Toggle layer visibility and disable layers. |
redaction.md | Enable redaction, mark regions, customize appearance, and handle events. |
pdf-coordinates.md | Coordinate conversion, scroll offsets, and ZoomToRect. |
organize-pages.md | Rotate, reorder, and remove pages; page organizer settings. |
handwritten-signature.md | Signature mode, appearance settings, flatten on save, and events. |
interaction-mode.md | Switch cursor modes (Selection, Panning, Marquee Zoom). |
pdf-pages.md | Page border customization, page interaction events, and pixel-to-point coordinate conversion on page click. |
saving-pdf-files.md | Save PDF, handle save events, cancel save, and check if the document has been edited. |
magnifying.md | Zoom level, zoom mode, zoom limits, and ZoomChanged event. |
searching-text.md | Search, highlight, navigate results, and retrieve text bounds. |
text-selection.md | Detect and retrieve selected text and bounds. |
localization.md | Apply .resx localization and set UI culture. |
customize-contextmenu.md | Add, remove, or hide context menu items. |
commands.md | Command bindings for navigation, zoom, annotations, print, and save; disable undo/redo via UndoRedoSettings.Limit. |
toolbar-items.md | Show/hide toolbar elements and disable individual toolbar items. |
---
Troubleshooting
| Issue | Solution |
|---|---|
| License warning at startup | Call SyncfusionLicenseProvider.RegisterLicense() inside the MainWindow constructor before InitializeComponent() |
| PDF not loading | Ensure the file path is correct and the file is not locked by another process; use Path.GetFullPath() for relative paths |
| Missing NuGet package | Run dotnet add package Syncfusion.PdfViewer.WPF or install via NuGet Package Manager |
| Toolbar item not found | Verify the template part name (e.g., PART_ButtonTextSearch) using the Syncfusion control template |
| Encrypted PDF dialog not suppressed | Handle the GetDocumentPassword event and set e.Handled = true to bypass the built-in dialog |
| Annotations not saving | Call pdfViewer.Save("output.pdf") or handle DocumentSaveInitiated to persist annotation changes |
---
Resources
---
License
Syncfusion WPF PdfViewer requires a commercial license for production use. A free community license is available for qualifying organizations.
Annotations in WPF Pdf Viewer
Annotation support in the Syncfusion WPF PdfViewer allows users to add, edit, delete, and manage various annotation types including ink, shapes, stamp, sticky note, text, text callout, text markup, file link, and more using the AnnotationMode property and annotation-specific settings.
Hyperlink Annotations in WPF Pdf Viewer
Hyperlink annotations are embedded link annotations inside the PDF content, such as URLs or document links created while authoring the PDF. These are handled through the Annotation subsystem, not through page navigation APIs.
The pdfViewer.Annotation.HyperLink property provides access to the hyperlink annotation controller, allowing you to enable or disable hyperlink interactions programmatically.
Access the Hyperlink Annotation Controller
var hyperlink = pdfViewer.Annotation.HyperLink;Enable Hyperlink Annotations
// Enable interaction with hyperlink annotations in the PDF
pdfViewer.Annotation.HyperLink.IsEnabled = true;Enable Ink Annotation Mode and Configure Color, Opacity, Thickness, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Ink;
pdfViewer.InkAnnotationSettings.InkColor = Colors.Green;
pdfViewer.InkAnnotationSettings.Opacity = 0.5f;
pdfViewer.InkAnnotationSettings.Thickness = 5;
pdfViewer.InkAnnotationSettings.Author = "Author";
pdfViewer.InkAnnotationSettings.Subject = "Ink Annotation";Switch to Ink Eraser Mode
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.InkEraser;Handle Ink Annotation Changes Using InkAnnotationChanged Event
pdfViewer.InkAnnotationChanged += PdfViewer_InkAnnotationChanged;
private void PdfViewer_InkAnnotationChanged(object sender, InkAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
int pageNumber = e.PageNumber;
PdfViewerInkSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
System.Windows.Media.Color color = settings.InkColor;
double thickness = settings.Thickness;
}Enable Shape Annotation Modes (Line,Rectangle,circle,polygon,polyline,Arrow) and Configure Color, Border Effect, Fill, and Line Style Settings
// Set annotation mode for desired shape
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Line;
pdfViewer.LineAnnotationSettings.LineColor = Colors.Blue;
pdfViewer.LineAnnotationSettings.Opacity = 0.5f;
pdfViewer.LineAnnotationSettings.Thickness = 5;
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Rectangle;
pdfViewer.RectangleAnnotationSettings.RectangleColor = Colors.Blue;
pdfViewer.RectangleAnnotationSettings.BorderEffect = BorderEffect.Cloudy;
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Circle;
pdfViewer.CircleAnnotationSettings.CircleColor = Colors.Blue;
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Polygon;
pdfViewer.PolygonAnnotationSettings.StrokeColor = Colors.Blue;
pdfViewer.PolygonAnnotationSettings.FillColor = Colors.Gray;
pdfViewer.PolygonAnnotationSettings.BorderEffect = BorderEffect.Cloudy;
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Polyline;
pdfViewer.PolylineAnnotationSettings.StrokeColor = Colors.Blue;
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Arrow;
pdfViewer.ArrowAnnotationSettings.StrokeColor = Colors.Blue;
pdfViewer.ArrowAnnotationSettings.FillColor = Colors.Blue;
pdfViewer.ArrowAnnotationSettings.BeginLineStyle = Syncfusion.Pdf.Interactive.PdfLineEndingStyle.OpenArrow;
pdfViewer.ArrowAnnotationSettings.EndLineStyle = Syncfusion.Pdf.Interactive.PdfLineEndingStyle.Diamond;Detect Shape Annotation Add, Edit, or Delete Actions with Type and Settings via ShapeAnnotationChanged Event
pdfViewer.ShapeAnnotationChanged += PdfViewer_ShapeAnnotationChanged;
private void PdfViewer_ShapeAnnotationChanged(object sender, ShapeAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
ShapeAnnotationType annotationType = e.Type;
int pageNumber = e.PageNumber;
ShapeAnnotationSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
float thickness = settings.Thickness;
}Enable Stamp Annotation Mode and Configure Icon, Opacity, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Stamp;
pdfViewer.StampAnnotationSettings.Opacity = 0.5f;
pdfViewer.StampAnnotationSettings.Icon = Syncfusion.Pdf.Interactive.PdfRubberStampAnnotationIcon.NotApproved;
pdfViewer.StampAnnotationSettings.Author = "Author";
pdfViewer.StampAnnotationSettings.Subject = "Stamp Annotation";Add a Custom Image Stamp Programmatically with Position and Size
int pageNumber = 1;
Image image = new Image() { Source = new BitmapImage(new Uri(@"stamp.png", UriKind.RelativeOrAbsolute)) };
PdfStampAnnotation stamp = new PdfStampAnnotation(image);
System.Windows.Point position = new System.Windows.Point(100, 100);
// Actual size
pdfViewer.AddStamp(stamp, pageNumber, position);
// Desired size
System.Windows.Size stampSize = new System.Windows.Size(200, 200);
pdfViewer.AddStamp(stamp, pageNumber, position, stampSize);Handle Stamp Annotation Changes Using StampAnnotationChanged Event
pdfViewer.StampAnnotationChanged += PdfViewer_StampAnnotationChanged;
private void PdfViewer_StampAnnotationChanged(object sender, StampAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
int pageNumber = e.PageNumber;
PdfViewerStampSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
PdfRubberStampAnnotationIcon icon = settings.Icon;
}Enable Sticky Note Annotation Mode and Configure Color, Icon, Opacity, Text, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.StickyNote;
pdfViewer.StickyNoteAnnotationSettings.Color = Colors.Red;
pdfViewer.StickyNoteAnnotationSettings.Opacity = 0.5f;
pdfViewer.StickyNoteAnnotationSettings.Icon = Syncfusion.Pdf.Interactive.PdfPopupIcon.Key;
pdfViewer.StickyNoteAnnotationSettings.Text = "Sticky Note";
pdfViewer.StickyNoteAnnotationSettings.Author = "Author";
pdfViewer.StickyNoteAnnotationSettings.Subject = "Sticky Note Annotation";Handle Sticky Note Annotation Changes Using StickyNoteAnnotationChanged Event
pdfViewer.StickyNoteAnnotationChanged += PdfViewer_StickyNoteAnnotationChanged;
private void PdfViewer_StickyNoteAnnotationChanged(object sender, StickyNoteAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
int pageNumber = e.PageNumber;
PdfViewerStickyNoteSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
PdfPopupIcon icon = settings.Icon;
}Enable FreeText Annotation Mode and Configure Background, Border Color, Font Color, Font Size, and Font Family Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.FreeText;
pdfViewer.FreeTextAnnotationSettings.Background = Colors.White;
pdfViewer.FreeTextAnnotationSettings.BorderColor = Colors.Blue;
pdfViewer.FreeTextAnnotationSettings.FontColor = Colors.Black;
pdfViewer.FreeTextAnnotationSettings.Opacity = 0.5f;
pdfViewer.FreeTextAnnotationSettings.FontSize = 16;
pdfViewer.FreeTextAnnotationSettings.FontFamily = new System.Windows.Media.FontFamily("Arial");Enable FreeText Callout Annotation Mode and Configure Intent and Callout Line Ending Style
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.FreeText;
pdfViewer.FreeTextAnnotationSettings.Intent = Syncfusion.Pdf.Interactive.PdfAnnotationIntent.FreeTextCallout;
pdfViewer.FreeTextAnnotationSettings.CalloutLineEndingStyle = Syncfusion.Pdf.Interactive.PdfLineEndingStyle.Diamond;Handle FreeText and Callout Annotation Changes Using FreeTextAnnotationChanged Event
pdfViewer.FreeTextAnnotationChanged += PdfViewer_FreeTextAnnotationChanged;
private void PdfViewer_FreeTextAnnotationChanged(object sender, FreeTextAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
int pageNumber = e.PageNumber;
PdfViewerFreeTextSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
System.Windows.Media.Color backgroundColor = settings.Background;
System.Windows.Media.Color borderColor = settings.BorderColor;
PdfAnnotationIntent calloutIntent = settings.Intent;
PdfLineEndingStyle calloutEndStyle = settings.CalloutLineEndingStyle;
}Enable Highlight Annotation Mode and Configure Color, Opacity, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Highlight;
pdfViewer.HighlightAnnotationSettings.HighlightColor = System.Windows.Media.Colors.Green;
pdfViewer.HighlightAnnotationSettings.Opacity = 0.5f;
pdfViewer.HighlightAnnotationSettings.Author = "Author";
pdfViewer.HighlightAnnotationSettings.Subject = "Highlight";Enable Underline Annotation Mode and Configure Color, Opacity, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Underline;
pdfViewer.UnderlineAnnotationSettings.UnderlineColor = System.Windows.Media.Colors.Blue;
pdfViewer.UnderlineAnnotationSettings.Opacity = 0.5f;
pdfViewer.UnderlineAnnotationSettings.Author = "Author";
pdfViewer.UnderlineAnnotationSettings.Subject = "Underline";Enable Strikethrough Annotation Mode and Configure Color, Opacity, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Strikethrough;
pdfViewer.StrikethroughAnnotationSettings.StrikethroughColor = System.Windows.Media.Colors.Blue;
pdfViewer.StrikethroughAnnotationSettings.Opacity = 0.5f;
pdfViewer.StrikethroughAnnotationSettings.Author = "Author";
pdfViewer.StrikethroughAnnotationSettings.Subject = "Strikethrough";Enable Squiggly Annotation Mode and Configure Color, Opacity, Author, and Subject Settings
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Squiggly;
pdfViewer.SquigglyAnnotationSettings.Color = System.Windows.Media.Colors.Blue;
pdfViewer.SquigglyAnnotationSettings.Opacity = 0.5f;
pdfViewer.SquigglyAnnotationSettings.Author = "Author";
pdfViewer.SquigglyAnnotationSettings.Subject = "Squiggly";Handle Text Markup Annotation Changes Using TextMarkupAnnotationChanged Event
pdfViewer.TextMarkupAnnotationChanged += PdfViewer_TextMarkupAnnotationChanged;
private void PdfViewer_TextMarkupAnnotationChanged(object sender, TextMarkupAnnotationChangedEventArgs e)
{
AnnotationChangedAction action = e.Action;
int pageNumber = e.PageNumber;
TextMarkupAnnotationType type = e.Type;
TextMarkupAnnotationSettings settings = e.Settings;
string author = settings.Author;
float opacity = settings.Opacity;
}Handle File Link Annotation Click to Retrieve File Path and Open Linked File
pdfViewer.FileLinkAnnotationClicked += PdfViewer_FileLinkAnnotationClicked;
private void PdfViewer_FileLinkAnnotationClicked(object sender, FileLinkAnnotationClickedEventArgs e)
{
int pageNumber = e.PageNumber;
RectangleF bounds = e.Bounds;
FileLinkAnnotationSettings settings = e.Settings;
string filePath = settings.FileName;
// Open file externally
System.Diagnostics.Process.Start(filePath);
}Configure Comments Panel Visibility and Expansion State
// Expand the comments pane
pdfViewer.CommentSettings.IsExpanded = true;
// Hide the comments button in annotation toolbar
pdfViewer.CommentSettings.IsVisible = false;Add an Ink Annotation Programmatically via PdfLoadedDocument
PdfLoadedDocument loadedDocument = pdfViewer.LoadedDocument;
List<float> inkPoints = new List<float> { 40, 300, 60, 100, 40, 50, 40, 300 };
RectangleF rectangle = new RectangleF(0, 0, 300, 400);
PdfInkAnnotation inkAnnotation = new PdfInkAnnotation(rectangle, inkPoints);
loadedDocument.Pages[0].Annotations.Add(inkAnnotation);Select an Annotation Programmatically by Name, Page Number, or Bring Into View
// Select by name
bool isSelected = pdfViewer.SelectAnnotation(inkAnnotationName);
// Select at a specific page
bool isSelected = pdfViewer.SelectAnnotation(inkAnnotationName, 1);
// Select and bring into view
bool isSelected = pdfViewer.SelectAnnotation(inkAnnotationName, 1, true);Hide or Show Annotations Programmatically by Name or Page Number
bool isHidden = pdfViewer.HideAnnotation(inkAnnotationName);
bool isShown = pdfViewer.ShowAnnotation(inkAnnotationName);
// By page
bool isHidden = pdfViewer.HideAnnotation(inkAnnotationName, 1);
bool isShown = pdfViewer.ShowAnnotation(inkAnnotationName, 1);Delete Annotations Programmatically by Name or Page, or Clear All Annotations
bool isDeleted = pdfViewer.DeleteAnnotation(inkAnnotationName);
// By page
bool isDeleted = pdfViewer.DeleteAnnotation(inkAnnotationName, 1);
// Delete all
pdfViewer.ClearAllAnnotations();
// Delete all on a specific page
pdfViewer.ClearAllAnnotations(1);Disable Annotation Selection Using AnnotationConstraints on DocumentLoaded
pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
{
pdfViewer.FreeTextAnnotationSettings.Constraints = ~AnnotationConstraints.Selectable;
}Set the Current User Name as Annotation Author Using the CurrentUser Property
pdfViewer.CurrentUser = "John";Placeholders
- Replace
"John"with the actual user name to set as the annotation author.
Change Annotation Selection Border Color
pdfViewer.SelectorSettings.StrokeColor = Color.FromArgb(255, 255, 0, 0);
pdfViewer.SelectorSettings.LockedStrokeColor = Color.FromArgb(255, 0, 255, 0);Locking Annotations
// Lock via default settings
pdfViewer.InkAnnotationSettings.IsLocked = true;
pdfViewer.FreeTextAnnotationSettings.IsLocked = true;
pdfViewer.HighlightAnnotationSettings.IsLocked = true;
pdfViewer.UnderlineAnnotationSettings.IsLocked = true;
pdfViewer.StrikethroughAnnotationSettings.IsLocked = true;
pdfViewer.StickyNoteAnnotationSettings.IsLocked = true;
pdfViewer.StampAnnotationSettings.IsLocked = true;
pdfViewer.RectangleAnnotationSettings.IsLocked = true;
pdfViewer.CircleAnnotationSettings.IsLocked = true;
pdfViewer.LineAnnotationSettings.IsLocked = true;
pdfViewer.ArrowAnnotationSettings.IsLocked = true;
pdfViewer.PolygonAnnotationSettings.IsLocked = true;
pdfViewer.PolylineAnnotationSettings.IsLocked = true;
// Lock via annotation changed event
pdfViewer.StickyNoteAnnotationChanged += Pdfviewer_StickyNoteAnnotationChanged;
private void Pdfviewer_StickyNoteAnnotationChanged(object sender, StickyNoteAnnotationChangedEventArgs e)
{
if (e.Action == AnnotationChangedAction.Add)
e.Settings.IsLocked = true;
}API Reference
| API | Type | Description |
|---|---|---|
AnnotationMode | Property | Sets the current annotation mode (Ink, InkEraser, Line, Rectangle, Circle, Arrow, Polygon, Polyline, Stamp, StickyNote, FreeText, Highlight, Underline, Strikethrough, Squiggly). |
InkAnnotationSettings.InkColor | Property | Color of the ink annotation. |
InkAnnotationSettings.Opacity | Property | Opacity of the ink annotation. |
InkAnnotationSettings.Thickness | Property | Thickness of the ink annotation. |
InkAnnotationSettings.IsLocked | Property | Locks the ink annotation from editing or deleting. |
InkAnnotationChanged | Event | Fires when an ink annotation is added, modified, or deleted. |
LineAnnotationSettings.LineColor | Property | Color of the line annotation. |
RectangleAnnotationSettings.RectangleColor | Property | Color of the rectangle annotation. |
RectangleAnnotationSettings.BorderEffect | Property | Border effect (Solid/Cloudy) of the rectangle. |
CircleAnnotationSettings.CircleColor | Property | Color of the circle annotation. |
ArrowAnnotationSettings.StrokeColor | Property | Stroke color of the arrow annotation. |
ArrowAnnotationSettings.BeginLineStyle | Property | Begin line ending style of the arrow. |
ArrowAnnotationSettings.EndLineStyle | Property | End line ending style of the arrow. |
PolygonAnnotationSettings.StrokeColor | Property | Stroke color of the polygon annotation. |
PolygonAnnotationSettings.FillColor | Property | Fill color of the polygon annotation. |
PolygonAnnotationSettings.BorderEffect | Property | Border effect (Solid/Cloudy) of the polygon. |
PolylineAnnotationSettings.StrokeColor | Property | Stroke color of the polyline annotation. |
ShapeAnnotationChanged | Event | Fires when a shape annotation is added, modified, or deleted. |
StampAnnotationSettings.Icon | Property | Icon type of the stamp annotation. |
StampAnnotationSettings.Opacity | Property | Opacity of the stamp annotation. |
AddStamp(stamp, pageNumber, position) | Method | Adds a custom stamp at the given position with actual size. |
AddStamp(stamp, pageNumber, position, size) | Method | Adds a custom stamp at the given position with desired size. |
StampAnnotationChanged | Event | Fires when a stamp annotation is added, modified, or deleted. |
StickyNoteAnnotationSettings.Color | Property | Color of the sticky note annotation. |
StickyNoteAnnotationSettings.Icon | Property | Icon type of the sticky note. |
StickyNoteAnnotationSettings.IsLocked | Property | Locks the sticky note from editing or deleting. |
StickyNoteAnnotationChanged | Event | Fires when a sticky note annotation is added, modified, or deleted. |
FreeTextAnnotationSettings.Background | Property | Background color of the text annotation. |
FreeTextAnnotationSettings.BorderColor | Property | Border color of the text annotation. |
FreeTextAnnotationSettings.FontColor | Property | Font color of the text annotation. |
FreeTextAnnotationSettings.FontSize | Property | Font size of the text annotation. |
FreeTextAnnotationSettings.FontFamily | Property | Font family of the text annotation. |
FreeTextAnnotationSettings.Intent | Property | Annotation intent (FreeTextCallout for callout annotations). |
FreeTextAnnotationSettings.CalloutLineEndingStyle | Property | End style of the callout arrow line. |
FreeTextAnnotationChanged | Event | Fires when a free text or callout annotation is added, modified, or deleted. |
HighlightAnnotationSettings.HighlightColor | Property | Color of the highlight annotation. |
UnderlineAnnotationSettings.UnderlineColor | Property | Color of the underline annotation. |
StrikethroughAnnotationSettings.StrikethroughColor | Property | Color of the strikethrough annotation. |
SquigglyAnnotationSettings.Color | Property | Color of the squiggly annotation. |
TextMarkupAnnotationChanged | Event | Fires when a highlight, underline, strikethrough, or squiggly annotation changes. |
FileLinkAnnotationClicked | Event | Fires when a file link annotation is clicked. |
FileLinkAnnotationClickedEventArgs.Settings.FileName | Property | File path linked to the annotation. |
CommentSettings.IsExpanded | Property | Expands or collapses the comments panel. |
CommentSettings.IsVisible | Property | Shows or hides the comments button in the annotation toolbar. |
SelectAnnotation(name) | Method | Selects an annotation by name. |
SelectAnnotation(name, pageNumber) | Method | Selects an annotation on a specific page. |
SelectAnnotation(name, bringIntoView) | Method | Selects an annotation and optionally scrolls it into view. |
HideAnnotation(name) | Method | Hides an annotation by name. |
ShowAnnotation(name) | Method | Shows a previously hidden annotation. |
DeleteAnnotation(name) | Method | Deletes an annotation by name. |
ClearAllAnnotations() | Method | Removes all annotations from the document. |
ClearAllAnnotations(pageNumber) | Method | Removes all annotations from a specific page. |
AnnotationSettings.IsLocked | Property | Locks an annotation to prevent moving, resizing, or deleting. |
AnnotationSettings.ModifiedDate | Property | Sets the modified date and time of an annotation. |
AnnotationChangedEventArgs.Name | Property | Gets or sets the unique name of the annotation. |
FreeTextAnnotationSettings.Constraints | Property | Controls selectability of free text annotations via AnnotationConstraints; use ~AnnotationConstraints.Selectable to disable selection. |
CurrentUser | Property | Sets the author name applied to newly added annotations. |
SelectorSettings.StrokeColor | Property | Border color of the selection rectangle for unlocked annotations. |
SelectorSettings.LockedStrokeColor | Property | Border color of the selection rectangle for locked annotations. |
Commands in WPF Pdf Viewer
The Syncfusion WPF PdfViewer provides built-in commands for page navigation, zoom, text search, annotations, undo/redo, print, save, and unload operations that can be bound directly to UI elements via XAML or executed in code-behind.
Navigate to First, Last, Previous, Next, and Specific Pages Using Button Click in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="First Page" Command="{Binding ElementName=pdfViewerControl, Path=FirstPageCommand, Mode=OneWay}" />
<Button Content="Last Page" Command="{Binding ElementName=pdfViewerControl, Path=LastPageCommand, Mode=OneWay}" />
<Button Content="Previous Page" Command="{Binding ElementName=pdfViewerControl, Path=PreviousPageCommand, Mode=OneWay}" />
<Button Content="Next Page" Command="{Binding ElementName=pdfViewerControl, Path=NextPageCommand, Mode=OneWay}" />
<Button Content="Go to Page 2" Command="{Binding ElementName=pdfViewerControl, Path=GoToPageCommand, Mode=OneWay}" CommandParameter="2" />Navigate to a Specific Page Using GoToPageCommandParameter in XAML
The GoToPageCommandParameter specifies the target page index for navigation.
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Go to Page 5"
Command="{Binding ElementName=pdfViewerControl, Path=GoToPageCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=GoToPageCommandParameter, Mode=Navigate to the First Page Using FirstPageCommandParameter in XAML
The FirstPageCommandParameter can be used to pass an optional parameter while executing the FirstPageCommand.
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="First Page"
Command="{Binding ElementName=pdfViewerControl, Path=FirstPageCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=FirstPageCommandParameter, Mode=OneWay}" />Navigate to the Last Page Using LastPageCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Last Page"
Command="{Binding ElementName=pdfViewerControl, Path=LastPageCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=LastPageCommandParameter, Mode=OneWay}" />Navigate to the Previous Page Using PreviousPageCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Previous Page"
Command="{Binding ElementName=pdfViewerControl, Path=PreviousPageCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=PreviousPageCommandParameter, Mode=OneWay}" />Navigate to the Next Page Using NextPageCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Next Page"
Command="{Binding ElementName=pdfViewerControl, Path=NextPageCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=NextPageCommandParameter, Mode=OneWay}" />Rotate Pages to a Specific Angle, Clockwise, or Counterclockwise Using Code-Behind
// Rotate page 6 to 180 degrees
pdfViewer.PageOrganizer.RotatePagesCommand.Execute(new object[] { new int[] { 5 }, PdfPageRotateAngle.RotateAngle180 });
// Rotate pages 1 and 2 clockwise by 90 degrees
pdfViewer.PageOrganizer.RotatePagesClockwiseCommand.Execute(new int[] { 0, 1 });
// Rotate pages 1 and 2 counterclockwise by 90 degrees
pdfViewer.PageOrganizer.RotatePagesCounterclockwiseCommand.Execute(new int[] { 0, 1 });Remove a Specific Page by Zero-Based Index Using Code-Behind
// Remove the 3rd page
pdfViewer.PageOrganizer.RemovePagesCommand.Execute(new int[] { 2 });Placeholders
- Replace
2with the zero-based index of the page to remove.
Zoom In and Zoom Out Using Button Click in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Zoom In" Command="{Binding ElementName=pdfViewerControl, Path=IncreaseZoomCommand, Mode=OneWay}" />
<Button Content="Zoom Out" Command="{Binding ElementName=pdfViewerControl, Path=DecreaseZoomCommand, Mode=OneWay}" />Increase Zoom Level Using IncreaseZoomCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Zoom In"
Command="{Binding ElementName=pdfViewerControl, Path=IncreaseZoomCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=IncreaseDecrease Zoom Level Using DecreaseZoomCommandParameter in XAML
The DecreaseZoomCommandParameter allows an optional parameter to be supplied when executing DecreaseZoomCommand.
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Zoom Out"
Command="{Binding ElementName=pdfViewerControl, Path=DecreaseZoomCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=DecreaseZoomCommandParameter, Mode=OneWay}" />Search Next and Previous Occurrences of a Keyword Using Button Click in XAML
<syncfusion:PdfViewerControl x:Name="PdfViewer" />
<Button Content="Search Next" Command="{Binding ElementName=PdfViewer, Path=SearchNextCommand, Mode=OneWay}" CommandParameter="keyword" />
<Button Content="Search Previous" Command="{Binding ElementName=PdfViewer, Path=SearchPreviousCommand, Mode=OneWay}" CommandParameter="keyword" />Placeholders
- Replace
keywordwith the text to search.
Search Using SearchNextCommandParameter and SearchPreviousCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="PdfViewer" />
<Button Content="Search Next"
Command="{Binding ElementName=PdfViewer, Path=SearchNextCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=PdfViewer, Path=SearchNextCommandParameter, Mode=OneWay}" />
<Button Content="Search Previous"
Command="{Binding ElementName=PdfViewer, Path=SearchPreviousCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=PdfViewer, Path=SearchPreviousCommandParameter, Mode=OneWay}" />Enable Highlight, Underline, Strikethrough, Shape, and Ink Annotation Modes Using Button Click in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Highlight" CommandParameter="Highlight" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Underline" CommandParameter="Underline" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Strikethrough" CommandParameter="Strikethrough" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Line" CommandParameter="Line" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Rectangle" CommandParameter="Rectangle" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Circle" CommandParameter="Circle" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Arrow" CommandParameter="Arrow" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />
<Button Content="Ink" CommandParameter="Ink" Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}" />Set Annotation Mode Using AnnotationCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Rectangle"
Command="{Binding ElementName=pdfViewerControl, Path=AnnotationCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=AnnotationCommandParameter, Mode=OneWay}" />Undo and Redo the Last Annotation Action Using Button Click in XAML
<syncfusion:PdfViewerControl x:Name="PdfViewer" />
<Button Content="Undo" Command="{Binding ElementName=PdfViewer, Path=UndoCommand, Mode=OneWay}" />
<Button Content="Redo" Command="{Binding ElementName=PdfViewer, Path=RedoCommand, Mode=OneWay}" />Disable Undo and Redo Functionality by Setting the History Limit to Zero
pdfViewer.UndoRedoSettings.Limit = 0;Undo and Redo Operations Using UndoRedoSettings (Code-Behind)
The UndoRedoSettings property of the WPF PdfViewer provides APIs to undo and redo user actions.
Undo and redo actions should always be performed only after checking their availability using CanUndo and CanRedo.
Undo the Most Recent Action Safely
Use CanUndo to determine whether an undo operation is possible before calling PerformUndo().
if (pdfViewer.UndoRedoSettings.CanUndo)
{
pdfViewer.UndoRedoSettings.PerformUndo();
}Redo the Most Recently Undone Action Safely
Use CanRedo to determine whether a redo operation is possible before calling PerformRedo().
if (pdfViewer.UndoRedoSettings.CanRedo)
{
pdfViewer.UndoRedoSettings.PerformRedo();
}Open the System Print Dialog Using Button Click in XAML
The print command opens the system print dialog, allowing the user to select a printer and configure print settings before sending the document to the printer. It can be bound to a button or menu item directly in XAML using standard WPF command binding. No additional parameters are required — invoking PrintCommand is sufficient to trigger the full print workflow. This command is useful for building custom toolbars where the built-in toolbar is hidden but printing functionality must still be exposed.
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Print" Command="{Binding ElementName=pdfViewerControl, Path=PrintCommand, Mode=OneWay}" />Open Print Dialog Using PrintCommandParameter in XAML
<syncfusion:PdfViewerControl x:Name="pdfViewerControl" />
<Button Content="Print"
Command="{Binding ElementName=pdfViewerControl, Path=PrintCommand, Mode=OneWay}"
CommandParameter="{Binding ElementName=pdfViewerControl, Path=PrintCommandParameter, Mode=OneWay}" />Save the Current PDF with Annotations and Form Data to a File Path Using Code-Behind
The save document command writes the current state of the loaded PDF — including any annotations, form field values, or page-level changes — to a file on disk. The target file path is passed directly as the command parameter when executing SaveDocumentCommand in code-behind. This is particularly important after annotation work, since all annotation types (ink, shape, text markup, stamp, sticky note, free text, etc.) are persisted into the saved file. If the path points to the same file that was loaded, the document is saved in-place; otherwise, a new file is created at the specified location.
pdfViewerControl.SaveDocumentCommand.Execute(@"C:\Output.pdf");Placeholders
- Replace
C:\Output.pdfwith the desired output file path.
Unload the Current PDF Document and Free Resources Using Button Click in XAML
The unload command releases the currently loaded PDF document from the viewer, clearing the display and freeing associated resources. It can be bound to a button in XAML and requires no command parameter. Unloading a document is useful when the user switches between files, closes a document explicitly, or when the application needs to free memory before loading a new PDF. After unloading, any unsaved annotation changes or edits will be lost, so it is good practice to invoke SaveDocumentCommand first if persistence is required.
<syncfusion:PdfViewerControl x:Name="PdfViewer" />
<Button Content="Unload" Command="{Binding ElementName=PdfViewer, Path=UnloadCommand, Mode=OneWay}" />API Reference for All Commands, Properties, and Binding Patterns
The table below summarizes every command and related property covered in this document. Commands are bindable via XAML Command / CommandParameter attributes or executable in code-behind using the .Execute() method. Properties under settings objects (e.g., UndoRedoSettings.Limit) must be set in code-behind before or after the relevant operation.
| API | Type | Description |
|---|---|---|
FirstPageCommand | Command | Navigates to the first page. |
FirstPageCommandParameter | Property | Optional parameter for first-page navigation. |
LastPageCommand | Command | Navigates to the last page. |
LastPageCommandParameter | Property | Optional parameter for last-page navigation. |
PreviousPageCommand | Command | Navigates to the previous page. |
PreviousPageCommandParameter | Property | Optional parameter for previous-page navigation. |
NextPageCommand | Command | Navigates to the next page. |
NextPageCommandParameter | Property | Optional parameter for next-page navigation. |
GoToPageCommand | Command | Navigates to the page specified by CommandParameter. |
GoToPageCommandParameter | Property | Specifies the target page number. |
PageOrganizer.RotatePagesCommand | Command | Rotates pages to a specified angle (0, 90, 180, 270). |
PageOrganizer.RotatePagesClockwiseCommand | Command | Rotates pages 90° clockwise from the current angle. |
PageOrganizer.RotatePagesCounterclockwiseCommand | Command | Rotates pages 90° counterclockwise from the current angle. |
PageOrganizer.RemovePagesCommand | Command | Removes pages at the specified zero-based indices. |
IncreaseZoomCommand | Command | Increases zoom by 25%. |
IncreaseZoomCommandParameter | Property | Optional parameter for zoom-in behavior. |
DecreaseZoomCommand | Command | Decreases zoom by 25%. |
DecreaseZoomCommandParameter | Property | Optional parameter for zoom-out behavior. |
SearchNextCommand | Command | Finds the next occurrence of the text in CommandParameter. |
SearchNextCommandParameter | Property | Specifies the text to search. |
SearchPreviousCommand | Command | Finds the previous occurrence of the text in CommandParameter. |
SearchPreviousCommandParameter | Property | Specifies the text to search. |
AnnotationCommand | Command | Sets annotation mode based on CommandParameter (Line, Circle, Rectangle, Arrow, Ink, Strikethrough, Highlight, Underline). |
UndoCommand | Command | Reverts the most recent action. |
RedoCommand | Command | Reapplies the most recently undone action. |
UndoRedoSettings.CanUndo | Property | Gets a value indicating whether the most recent action can be undone. |
UndoRedoSettings.CanRedo | Property | Gets a value indicating whether the most recent undone action can be redone. |
UndoRedoSettings.PerformUndo() | Method | Undoes the most recent action if undo is available. |
UndoRedoSettings.PerformRedo() | Method | Redoes the most recently undone action. |
UndoRedoSettings.Limit | Property | Maximum number of undo/redo steps; set to 0 to disable undo/redo entirely. |
PrintCommand | Command | Opens the print dialog. |
PrintCommandParameter | Property | Optional parameter for print behavior. |
SaveDocumentCommand | Command | Saves the PDF to the file path passed as the command parameter. |
UnloadCommand | Command | Unloads the currently loaded PDF document. |
Customize Context Menu in WPF Pdf Viewer
The Syncfusion WPF PdfViewer supports customization of the default context menu items for Annotation, Text Selection, Redaction, and Signature Field using ContextMenuOpening and ContextMenuItemClickedEvent events.
Wire Context Menu Opening and Item Clicked Events to Handle and Customize the Context Menu Using Code-Behind
pdfViewer.ContextMenuOpening += PdfViewer_ContextMenuOpening;
pdfViewer.ContextMenuItemClickedEvent += PdfViewer_ContextMenuItemClickedEvent;Add a Custom Menu Item to the Annotation, Redaction, Text Selection, or Signature Field Context Menu Using Code-Behind
private void PdfViewer_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
if (e.Source == "Annotation")
{
e.MenuItems.Insert(0, new ContextMenuItem { Content = "Lock Annotation" });
e.MenuItems.Add(new ContextMenuItem { Content = "New Menu Item" });
}
if (e.Source == "Redaction")
e.MenuItems.Add(new ContextMenuItem { Content = "New Menu Item" });
if (e.Source == "Text Selection")
e.MenuItems.Add(new ContextMenuItem { Content = "New Menu Item" });
if (e.Source == "Signature Field")
e.MenuItems.Add(new ContextMenuItem { Content = "New Menu Item" });
}Remove an Existing Menu Item from the Annotation or Text Selection Context Menu by Content Name Using Code-Behind
private void PdfViewer_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
if (e.Source == "Annotation")
{
var item = e.MenuItems.FirstOrDefault(i => i.Content == "Delete");
if (item != null) e.MenuItems.Remove(item);
}
if (e.Source == "Text Selection")
{
var item = e.MenuItems.FirstOrDefault(i => i.Content == "Copy");
if (item != null) e.MenuItems.Remove(item);
}
}Hide the Context Menu for Annotation, Redaction, Text Selection, or Signature Field by Setting Handled to True Using Code-Behind
private void PdfViewer_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
if (e.Source == "Annotation")
e.Handled = true;
if (e.Source == "Redaction")
e.Handled = true;
if (e.Source == "Text Selection")
e.Handled = true;
if (e.Source == "Signature Field")
e.Handled = true;
}Handle Context Menu Item Click and Suppress the Default Action to Retrieve Clicked Item Details Using Code-Behind
private void PdfViewer_ContextMenuItemClickedEvent(object sender, ContextMenuItemClickedEventArgs e)
{
// Suppress default action
e.Handled = true;
// Retrieve clicked item details
MessageBox.Show($"Source: {e.Source}\nClicked Item: {e.MenuItem.Content}");
}API Reference for All Context Menu Events, Event Arguments, and Properties
| API | Type | Description |
|---|---|---|
ContextMenuOpening | Event | Triggered before the context menu is displayed; allows dynamic modification of menu items. |
ContextMenuItemClickedEvent | Event | Triggered when a context menu item is clicked. |
ContextMenuOpeningEventArgs.Source | Property | Identifies the source type: "Annotation", "Redaction", "Text Selection", or "Signature Field". |
ContextMenuOpeningEventArgs.MenuItems | Property | Collection of ContextMenuItem objects to add, remove, or reorder. |
ContextMenuOpeningEventArgs.Handled | Property | Set to true to suppress the context menu from appearing. |
ContextMenuItem.Content | Property | Text label of the context menu item. |
ContextMenuItemClickedEventArgs.Source | Property | Source type of the context menu that was clicked. |
ContextMenuItemClickedEventArgs.MenuItem | Property | The ContextMenuItem that was clicked. |
ContextMenuItemClickedEventArgs.Handled | Property | Set to true to prevent the default click action. |
Exporting PDF Pages as Images in WPF Pdf Viewer
The Syncfusion WPF PdfViewer supports exporting PDF pages as images (JPG, PNG, TIFF, BMP) via the ExportAsImage API.
---
Export a Single PDF Page as a JPEG, PNG, TIFF, or BMP Image Using ExportAsImage in Code-Behind
Exports a single PDF page to a BitmapSource by passing the zero-based page index to ExportAsImage.
PdfViewerControl pdfViewer = new PdfViewerControl();
// Load the input PDF file.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Sample.pdf");
pdfViewer.Load(loadedDocument);
// Export the page at index 0 as a BitmapSource.
BitmapSource image = pdfViewer.ExportAsImage(0);
string output = @"..\..\Output\Image";
if (image != null)
{
// Initialize a JPEG encoder.
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
// Save the image to the output path.
FileStream stream = new FileStream(output + ".Jpeg", FileMode.Create);
encoder.Save(stream);
}
loadedDocument.Dispose();
loadedDocument = null;Placeholders
- Replace
Sample.pdfwith the actual PDF file path. - Replace
outputpath with the desired output directory. - Swap
JpegBitmapEncoderwithPngBitmapEncoder,TiffBitmapEncoder, orBmpBitmapEncoderto export in PNG, TIFF, or BMP format respectively.
---
Export a Contiguous Range of PDF Pages as Images into a BitmapSource Array Using ExportAsImage in Code-Behind
Exports a contiguous range of PDF pages to a BitmapSource[] array by passing the start and end page indexes to ExportAsImage.
PdfViewerControl pdfViewer = new PdfViewerControl();
// Load the input PDF file.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Sample.pdf");
pdfViewer.Load(loadedDocument);
// Export all pages as images.
BitmapSource[] images = pdfViewer.ExportAsImage(0, loadedDocument.Pages.Count - 1);
string output = @"..\..\Output\Image";
if (images != null)
{
for (int i = 0; i < images.Length; i++)
{
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(images[i]));
FileStream stream = new FileStream(output + i.ToString() + ".Jpeg", FileMode.Create);
encoder.Save(stream);
}
}
loadedDocument.Dispose();
loadedDocument = null;Placeholders
- Replace
Sample.pdfwith the actual PDF file path. - Replace
outputpath with the desired output directory. - Adjust the start/end page indexes to export only a subset of pages.
---
Export a Single PDF Page as an Image at a Custom Pixel Width and Height with Optional Aspect Ratio Preservation Using ExportAsImage in Code-Behind
Exports a single PDF page as an image at a specified pixel width and height by passing a SizeF to ExportAsImage. Set keepAspectRatio to true to preserve the original page proportions.
// Export page at index 0 with a custom size of 1836 x 2372 pixels.
BitmapSource image = pdfViewer.ExportAsImage(0, new SizeF(1836, 2372), false);
string output = @"..\..\Output\Image";
if (image != null)
{
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
FileStream stream = new FileStream(output + ".Jpeg", FileMode.Create);
encoder.Save(stream);
}Placeholders
- Replace the
SizeFvalues with the required width and height in pixels. - Pass
trueas the third argument to maintain the aspect ratio of the output image.
---
Export a Range of PDF Pages as Images at a Custom Horizontal and Vertical DPI Resolution Using ExportAsImage in Code-Behind
Exports a range of PDF pages as images at a specified horizontal (DpiX) and vertical (DpiY) resolution using ExportAsImage.
int startPageIndex = 0;
int endPageIndex = 3;
float dpiX = 200;
float dpiY = 200;
BitmapSource[] images = pdfViewer.ExportAsImage(startPageIndex, endPageIndex, dpiX, dpiY);
string output = @"..\..\Output\Image";
if (images != null)
{
for (int i = 0; i < images.Length; i++)
{
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(images[i]));
FileStream stream = new FileStream(output + i.ToString() + ".Jpeg", FileMode.Create);
encoder.Save(stream);
}
}Placeholders
- Adjust
startPageIndexandendPageIndexto the desired page range. - Replace
dpiXanddpiYwith the required resolution values.
Export a Single PDF Page as an Image with Transparency Control
Exports a single PDF page to a BitmapSource while optionally preserving transparency.
BitmapSource image = pdfViewer.ExportAsImage(0, true);Export a Range of PDF Pages as Images with Transparency Control
Exports a contiguous range of pages as a BitmapSource[].
BitmapSource[] images = pdfViewer.ExportAsImage(0, 3, true);Export a Single PDF Page with Custom Size, DPI, and Aspect Ratio
Exports a single page with full control over image size, resolution, aspect ratio, and transparency.
BitmapSource image = pdfViewer.ExportAsImage(
pageIndex: 0,
customSize: new SizeF(1836, 2372),
dpiX: 300f,
dpiY: 300f,
keepAspectRatio: true,
keepTransparency: false
);Export a Range of PDF Pages with Custom DPI
BitmapSource[] images = pdfViewer.ExportAsImage(
startIndex: 0,
endIndex: 2,
dpiX: 200f,
dpiY: 200f,
keepTransparency: true
);Extract Text from PDF Files in WPF Pdf Viewer
The Syncfusion WPF PdfViewer allows you to extract text from a specific page or the entire PDF file using the ExtractText method of PdfDocumentView. Text can also be retrieved with line and word bounds via TextLines and TextLine.
Extract Text from a Particular Page by Passing a Zero-Based Page Index Using ExtractText
Extracts text from a single page by passing the zero-based page index to ExtractText.
PdfDocumentView pdfDocumentView = new PdfDocumentView();
pdfDocumentView.Load(@"Sample.pdf");
TextLines textLines = new TextLines();
string extractedText = pdfDocumentView.ExtractText(0, out textLines);Placeholders
- Replace
Sample.pdfwith the actual PDF file path. - Change
0to the required zero-based page index.
Extract Text from an Entire PDF File by Iterating All Pages Using PageCount and ExtractText
Iterates over all pages using PageCount and concatenates the extracted text from each page.
PdfDocumentView pdfDocumentView = new PdfDocumentView();
pdfDocumentView.Load(@"Sample.pdf");
TextLines textLines = new TextLines();
string extractedText = string.Empty;
for (int i = 0; i < pdfDocumentView.PageCount; i++)
{
extractedText += pdfDocumentView.ExtractText(i, out textLines);
}Placeholders
- Replace
Sample.pdfwith the actual PDF file path.
Extract Text with Line Bounds and Bounding Rectangles Using TextLines Output from ExtractText
Retrieves text line by line along with each line's bounding rectangle using the TextLines output from ExtractText.
PdfDocumentView pdfDocumentView = new PdfDocumentView();
pdfDocumentView.Load(@"Sample.pdf");
TextLines textLines = new TextLines();
pdfDocumentView.ExtractText(0, out textLines);
TextLine line = textLines[0];
string text = line.Text;
RectangleF lineBounds = line.Bounds;Placeholders
- Replace
Sample.pdfwith the actual PDF file path. - Change
0inExtractTextto the required page index. - Change
textLines[0]to access a different line.
Extract Text with Word Bounds and Bounding Rectangles Using WordCollection Property of TextLine
Retrieves individual words within a line along with each word's bounding rectangle using the WordCollection property of TextLine.
PdfDocumentView pdfDocumentView = new PdfDocumentView();
pdfDocumentView.Load(@"Sample.pdf");
TextLines textLines = new TextLines();
pdfDocumentView.ExtractText(0, out textLines);
TextLine line = textLines[0];
List<TextWord> wordCollection = line.WordCollection;
string word = wordCollection[0].Text;
RectangleF bounds = wordCollection[0].Bounds;Placeholders
- Replace
Sample.pdfwith the actual PDF file path. - Change
0inExtractTextto the required page index. - Change
textLines[0]andwordCollection[0]to access different lines or words.
````
Get the Index of the Currently Displayed Page Using Code-Behind
int currentPage = pdfViewer.CurrentPageIndex;Form Filling in PDF Files in WPF Pdf Viewer
The Syncfusion WPF PdfViewer supports filling, editing, flattening, and saving AcroForm fields. You can also import/export form data and add, remove, or modify form fields at runtime.
Configure Form Settings Using FormSettings
The FormSettings property provides access to settings that control the behavior and appearance of PDF form fields in the viewer.
Show or Hide Form Field Icons Using IsIconVisible
The IsIconVisible property determines whether icons associated with form fields are displayed in the PDF viewer.
pdfViewer.FormSettings.IsIconVisible = true; Notes
- When set to true, form field icons are displayed.
- When set to false, form field icons are hidden.
Retrieve Clicked Form Field Details by Type Using the FormFieldClicked Event in Code-Behind
Retrieves details of a clicked form field using the FormFieldClicked event.
//Wire the FormFieldClicked event.
pdfViewer.FormFieldClicked += PdfViewer_FormFieldClicked;
private void PdfViewer_FormFieldClicked(object sender, FormFieldClickedEventArgs args)
{
if (args.FormField is TextBox)
{
TextBox text = args.FormField as TextBox;
}
else if (args.FormField is PasswordBox)
{
PasswordBox passTextBox = args.FormField as PasswordBox;
}
else if (args.FormField is ListBox)
{
ListBox listBox = args.FormField as ListBox;
}
else if (args.FormField is ComboBox)
{
ComboBox comboBox = args.FormField as ComboBox;
}
else if (args.FormField is CheckBox)
{
CheckBox checkBox = args.FormField as CheckBox;
}
else if (args.FormField is RadioButton)
{
RadioButton radioBtn = args.FormField as RadioButton;
}
}Import Form Data from an FDF File into a PDF Document with AcroForm Fields Using Code-Behind
Imports form data into a PDF document with AcroForm fields.
//Import PDF form data
pdfViewer.ImportFormData("Import.fdf", Syncfusion.Pdf.Parsing.DataFormat.Fdf);Placeholders
- Replace
Import.fdfwith the actual import file path.
Import Form Data from a Byte Array (Overload)
Imports form data provided as a byte array into a PDF document with AcroForm fields.
byte[] formData = File.ReadAllBytes("Import.fdf");
pdfViewer.ImportFormData(
formData,
Syncfusion.Pdf.Parsing.DataFormat.Fdf);Export Form Data from a PDF Document to an FDF File Using Code-Behind
Exports form data from a PDF document to a file.
//Export PDF form data
pdfViewer.ExportFormData("Export.fdf", Syncfusion.Pdf.Parsing.DataFormat.Fdf, "SourceForm.pdf");Placeholders
- Replace
Export.fdfwith the desired export file path. - Replace
SourceForm.pdfwith the source PDF file name.
Add a Text Box Form Field Programmatically to a Page at Runtime Using Code-Behind
Adds a text box form field programmatically to the first page of the loaded document.
PdfLoadedPage page = pdfViewer.LoadedDocument.Pages[0] as PdfLoadedPage;
PdfTextBoxField textBoxField = new PdfTextBoxField(page, "FirstName");
textBoxField.Bounds = new RectangleF(0, 0, 100, 20);
pdfViewer.LoadedDocument.Form.Fields.Add(textBoxField);Remove a Form Field at a Specified Index from the Loaded Document at Runtime Using Code-Behind
Removes a form field at a specified index from the loaded document.
if (pdfViewer.LoadedDocument.Form.Fields.Count > 0)
pdfViewer.LoadedDocument.Form.Fields.RemoveAt(0);Modify the Text of an Existing Text Box Form Field at a Specified Index at Runtime Using Code-Behind
Modifies the text of an existing text box form field at a specified index.
if (pdfViewer.LoadedDocument.Form.Fields[0] is PdfLoadedTextBoxField)
{
(pdfViewer.LoadedDocument.Form.Fields[0] as PdfLoadedTextBoxField).Text = "Syncfusion";
}Handwritten Signature in WPF Pdf Viewer
Handwritten signature support in the Syncfusion WPF PdfViewer allows users to draw, add, and customize signatures in PDF documents using HandwrittenSignatureSettings and AddHandwrittenSignature.
Enable Handwritten Signature Annotation Mode to Allow Users to Draw Signatures on a PDF Using Code-Behind
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.HandwrittenSignature;Placeholders
- Replace
sample.pdfwith the actual PDF file path.
Set the Stroke Color and Opacity of Handwritten Signatures Using HandwrittenSignatureSettings in Code-Behind
pdfViewer.HandwrittenSignatureSettings.Opacity = 0.5F;
pdfViewer.HandwrittenSignatureSettings.Color = Colors.Green;Flatten Handwritten Signatures into the PDF Page Content on Save Using FlattenSignatureOnSave in Code-Behind
pdfViewer.HandwrittenSignatureSettings.FlattenSignatureOnSave = true;Add a Handwritten Signature to a Single PDF Page at Specified Bounds Using AddHandwrittenSignature in Code-Behind
System.Windows.Shapes.Path signature = new System.Windows.Shapes.Path();
// Set signature appearance as Data for the path here.
pdfViewer.AddHandwrittenSignature(signature, 1, new RectangleF(450, 750, 100, 100));Placeholders
- Replace
1with the target 1-based page number. - Replace
RectangleF(450, 750, 100, 100)with the actual bounds.
Add a Handwritten Signature to Multiple PDF Pages with Per-Page Bounds Using AddHandwrittenSignature and a Dictionary in Code-Behind
System.Windows.Shapes.Path signature = new System.Windows.Shapes.Path();
// Set signature appearance using Data property of the path here.
Dictionary<int, List<RectangleF>> bounds = new Dictionary<int, List<RectangleF>>();
bounds.Add(1, new List<RectangleF>() { new RectangleF(450, 750, 100, 100) });
bounds.Add(2, new List<RectangleF>() { new RectangleF(350, 550, 200, 200) });
pdfViewer.AddHandwrittenSignature(signature, bounds);Handle Add, Move, Resize, Select, and Remove Actions on Handwritten Signatures Using the HandwrittenSignatureChanged Event in Code-Behind
pdfViewer.HandwrittenSignatureChanged += PdfViewer_HandwrittenSignatureChanged;
private void PdfViewer_HandwrittenSignatureChanged(object sender, HandwrittenSignatureChangedEventArgs e)
{
if (e.Action == AnnotationChangedAction.Add)
{
System.Windows.Shapes.Path signature = e.Signature as System.Windows.Shapes.Path;
}
else if (e.Action == AnnotationChangedAction.Move)
{
PointF oldLocation = e.OldBounds.Location;
PointF newLocation = e.NewBounds.Location;
}
else if (e.Action == AnnotationChangedAction.Select)
{
int pageNumber = e.PageNumber;
PointF location = e.NewBounds.Location;
SizeF size = e.NewBounds.Size;
}
}Placeholders
- Replace
sample.pdfwith the actual PDF file path.
API Reference for All Handwritten Signature Properties, Methods, Events, and Event Arguments
| API | Type | Description |
|---|---|---|
AnnotationMode | Property | Sets the annotation mode; use PdfViewerAnnotationMode.HandwrittenSignature to enable signature mode. |
HandwrittenSignatureSettings.Opacity | Property | Sets the opacity (0.0 to 1.0) of the handwritten signature. |
HandwrittenSignatureSettings.Color | Property | Sets the stroke color of the handwritten signature. |
HandwrittenSignatureSettings.FlattenSignatureOnSave | Property | Flattens the signature on save when set to true; otherwise saved as ink annotation. |
AddHandwrittenSignature(path, pageNumber, bounds) | Method | Adds a signature to a single page at the specified bounds. |
AddHandwrittenSignature(path, bounds) | Method | Adds a signature to multiple pages using a dictionary of page numbers and bounds. |
HandwrittenSignatureChanged | Event | Fires when a handwritten signature is added, moved, resized, selected, or removed. |
HandwrittenSignatureChangedEventArgs.Action | Property | Type of change (Add, Move, Resize, Select, Remove). |
HandwrittenSignatureChangedEventArgs.Signature | Property | The signature as System.Windows.Shapes.Path. |
HandwrittenSignatureChangedEventArgs.OldBounds | Property | Previous bounds of the signature (location and size). |
HandwrittenSignatureChangedEventArgs.NewBounds | Property | New bounds of the signature (location and size). |
HandwrittenSignatureChangedEventArgs.PageNumber | Property | 1-based page number where the signature is located. |
Importing and Exporting Annotations in WPF Pdf Viewer
The Syncfusion WPF PdfViewer supports exporting and importing annotation data in FDF or XFDF formats via the ExportAnnotations and ImportAnnotations APIs.
---
Export All Annotations from a Loaded PDF to an FDF or XFDF File Using ExportAnnotations in Code-Behind
Exports all annotations in the loaded PDF to a file using ExportAnnotations. Choose AnnotationDataFormat.fdf or AnnotationDataFormat.xfdf as required.
// Export annotations to an FDF file.
pdfViewer.ExportAnnotations("Annotation.fdf", AnnotationDataFormat.fdf);
// Export annotations to an XFDF file.
pdfViewer.ExportAnnotations("Annotation.xfdf", AnnotationDataFormat.xfdf);Placeholders
- Replace
"Annotation.fdf"/"Annotation.xfdf"with the desired output file path.
---
Export All Annotations from a Loaded PDF to a Memory Stream in FDF or XFDF Format for In-Memory Processing Using ExportAnnotations in Code-Behind
Exports all annotations in the loaded PDF to a Stream instead of a file, useful for in-memory processing or network transfer.
// Export annotations to a memory stream in FDF format.
Stream stream = new MemoryStream();
pdfViewer.ExportAnnotations(stream, AnnotationDataFormat.fdf);Placeholders
- Replace
AnnotationDataFormat.fdfwithAnnotationDataFormat.xfdfto export in XFDF format.
---
Import Annotations from an FDF or XFDF File and Apply Them to the Currently Loaded PDF Document Using ImportAnnotations in Code-Behind
Imports annotations from an FDF or XFDF file and applies them to the currently loaded PDF document using ImportAnnotations.
// Import annotations from an FDF file.
pdfViewer.ImportAnnotations("Annotation.fdf", AnnotationDataFormat.fdf);
// Import annotations from an XFDF file.
pdfViewer.ImportAnnotations("Annotation.xfdf", AnnotationDataFormat.xfdf);Placeholders
- Replace
"Annotation.fdf"/"Annotation.xfdf"with the path to the annotation file to import.
---
Import Annotations from a Stream Containing FDF or XFDF Data and Apply Them to the Currently Loaded PDF Document Using ImportAnnotations in Code-Behind
Imports annotations from a Stream containing FDF or XFDF data and applies them to the currently loaded PDF document.
// Import annotations from a stream in FDF format.
pdfViewer.ImportAnnotations(stream, AnnotationDataFormat.fdf);Placeholders
- Replace
AnnotationDataFormat.fdfwithAnnotationDataFormat.xfdfto import XFDF data. - Ensure
streamis positioned at the beginning before callingImportAnnotations.
Interaction Modes in WPF Pdf Viewer
Interaction mode support in the Syncfusion WPF PdfViewer allows switching between Selection, Panning, and Marquee Zoom cursor modes using the CursorMode property.
Enable Text Selection Mode to Allow Users to Select and Copy Text Using Code-Behind
pdfViewerControl.CursorMode = PdfViewerCursorMode.SelectTool;
pdfViewerControl.Load(@"sample.pdf");Enable Panning Mode to Allow Users to Drag and Scroll Through PDF Pages Using Code-Behind
pdfViewerControl.CursorMode = PdfViewerCursorMode.HandTool;
pdfViewerControl.Load(@"sample.pdf");Enable Marquee Zoom Mode to Allow Users to Zoom Into a Selected Area Using Code-Behind
pdfViewerControl.CursorMode = PdfViewerCursorMode.MarqueeZoom;
pdfViewerControl.Load(@"sample.pdf");Placeholders
- Replace
sample.pdfwith the actual PDF file path.
Set Custom Cursor for PdfViewerControl Using Code-Behind
In addition to the predefined cursor interaction modes, the cursor for the PDF viewer control can be explicitly set using the Cursor property.
pdfViewer.Cursor = Cursors.Pen;Notes
- This sets the mouse cursor appearance when it is over the PdfViewerControl.
- Any cursor from System.Windows.Input.Cursors can be assigned.
- Cursor appearance is independent of the CursorMode setting.
API Reference for Cursor Modes, Properties, and Enum Values
| API | Type | Description |
|---|---|---|
CursorMode | Property | Gets or sets the cursor interaction mode for the PDF Viewer. |
Cursor | Property | Gets or sets the mouse cursor used for the PdfViewer control. |
PdfViewerCursorMode.SelectTool | Enum Value | Enables text selection mode (default). |
PdfViewerCursorMode.HandTool | Enum Value | Enables panning mode for dragging and scrolling pages. |
PdfViewerCursorMode.MarqueeZoom | Enum Value | Enables marquee zoom mode to zoom into a selected area. |
Load PDF Files in WPF Pdf Viewer
Loading PDF files in the Syncfusion WPF PdfViewer is done through the Load API and the ItemSource property, which support opening both normal and encrypted documents. PDFs can be loaded from file paths, streams, or PdfLoadedDocument objects, and also via XAML data binding using ItemSource, enabling flexible integration within WPF applications.Asynchronous loading helps improve UI responsiveness, especially when loading large PDF files.
Add PdfViewerControl to the Main Window Using XAML
Add the PdfViewerControl in the MainWindow.xaml.
<Window
x:Class="PdfViewerDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF">
<Grid>
<syncfusion:PdfViewerControl x:Name="pdfViewer"></syncfusion:PdfViewerControl>
</Grid>
</Window>Load a Normal PDF from a File Path Using Code-Behind
//Load PDF file using the file path.
pdfViewer.Load(@"customer.pdf");Placeholders
Replace customer.pdf with the customer-given PDF file path.
Load a Normal PDF from a Stream Using Code-Behind
FileStream stream = new FileStream(@"customer.pdf", FileMode.Open);
//Load PDF file using stream.
pdfViewer.Load(stream);Placeholders
Replace customer.pdf with the customer-given PDF file path.
Load a Password-Protected PDF from a File Path Using Code-Behind
//Load password protected PDF file using the file path and the password.
pdfViewer.Load(@"customer.pdf", "password");Placeholders
- Replace
customer.pdfwith the customer-given PDF file path. - Replace
"password"with the actual password of the PDF.
Load a Password-Protected PDF from a Stream Using Code-Behind
FileStream stream = new FileStream(@"customer.pdf", FileMode.Open);
//Load password protected PDF file using stream and the password.
pdfViewer.Load(stream, "password");Placeholders
- Replace
customer.pdfwith the customer-given PDF file path. - Replace
"password"with the actual password of the PDF.
Load PDF Files Asynchronously Using LoadAsync
The LoadAsync APIs load PDF documents without blocking the UI thread and return a Task<bool> indicating whether the load operation succeeded.
Load a PDF Using PdfLoadedDocument Asynchronously
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"customer.pdf");
bool isLoaded = await pdfViewer.LoadAsync(loadedDocument);Load a Normal PDF from a Stream Asynchronously
FileStream stream = new FileStream(@"customer.pdf", FileMode.Open, FileAccess.Read);
bool isLoaded = await pdfViewer.LoadAsync(stream);Load a Password-Protected PDF from a Stream Asynchronously
FileStream stream = new FileStream(@"customer.pdf", FileMode.Open, FileAccess.Read);
bool isLoaded = await pdfViewer.LoadAsync(stream, "password");Load a Normal PDF from a File Path Asynchronously
bool isLoaded = await pdfViewer.LoadAsync(@"customer.pdf");Load a Password-Protected PDF from a File Path Asynchronously
bool isLoaded = await pdfViewer.LoadAsync(@"customer.pdf", "password");- All LoadAsync overloads must be awaited.
- Recommended for large documents or when UI responsiveness is critical.
- The returned bool indicates whether the load operation completed successfully.
Placeholders
- Replace
customer.pdfwith the customer-given PDF file path. - Replace
"password"with the actual password of the PDF.
Load a PDF Using the ItemSource Property with a File Path in Code-Behind
The ItemSource property of PdfViewerControl accepts a string file path, a Stream, or a PdfLoadedDocument object to load a PDF.
//Load PDF file using the ItemSource property.
pdfViewer.ItemSource = @"customer.pdf";Placeholders
Replace customer.pdf with the customer-given PDF file path.
Load a PDF Using the ItemSource Property with a Stream in Code-Behind
//Load PDF file as Stream using the ItemSource property.
pdfViewer.ItemSource = new FileStream(@"customer.pdf", FileMode.Open);Placeholders
Replace customer.pdf with the customer-given PDF file path.
Load a PDF Using the ItemSource Property with a PdfLoadedDocument Object in Code-Behind
//Load PDF file as PdfLoadedDocument object using the ItemSource property.
PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(@"customer.pdf");
pdfViewer.ItemSource = pdfLoadedDocument;Placeholders
Replace customer.pdf with the customer-given PDF file path.
Load a PDF by Binding the ItemSource Property to a ViewModel Using XAML and MVVM
You can bind the ItemSource property directly in XAML using a ViewModel, enabling MVVM-based PDF loading.
MainWindow.xaml
<Window
x:Class="PdfViewerDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
xmlns:local="clr-namespace:PdfViewerDemo">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<syncfusion:PdfViewerControl x:Name="pdfViewer"
ItemSource="{Binding PdfFilePath}">
</syncfusion:PdfViewerControl>
</Grid>
</Window>MainWindow.xaml.cs
public MainWindow()
{
InitializeComponent();
}MainViewModel.cs
public class MainViewModel : INotifyPropertyChanged
{
private string _pdfFilePath;
public string PdfFilePath
{
get { return _pdfFilePath; }
set
{
_pdfFilePath = value;
OnPropertyChanged(nameof(PdfFilePath));
}
}
public MainViewModel()
{
//Set the PDF file path to load via binding.
PdfFilePath = @"customer.pdf";
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}Placeholders
Replace customer.pdf with the customer-given PDF file path.
Unload the Current PDF Document and Free Resources Using Code-Behind
pdfViewer.Unload(true);Change the Loading Indicator Spinner Color Using Code-Behind
pdfViewer.LoadingIndicator.LoaderColor = System.Windows.Media.Color.FromArgb(255, 255, 0, 0);Change the Loading Indicator Message Text Using Code-Behind
pdfViewer.LoadingIndicator.LoadingMessage = "Document loading";Suppress the Built-In Password Dialog and Supply the Password Programmatically Using Code-Behind
To suppress the built-in password prompt and supply the password programmatically, handle the GetDocumentPassword event and set e.Handled = true.
pdfViewer.GetDocumentPassword += PdfViewer_GetDocumentPassword;
string filePath = Path.GetFullPath(@"customer.pdf");
pdfViewer.Load(filePath);
private void PdfViewer_GetDocumentPassword(object sender, GetDocumentPasswordEventArgs e)
{
System.Security.SecureString secureString = new System.Security.SecureString();
foreach (char c in "password")
secureString.AppendChar(c);
e.Password = secureString;
// Set Handled to true to hide the built-in password dialog.
e.Handled = true;
}Placeholders
- Replace
customer.pdfwith the customer-given PDF file path. - Replace
"password"with the actual password characters for the PDF.
Apply a Theme to WPF PdfViewerControl Using SfSkinManager
The WPF PdfViewerControl supports built-in themes via SfSkinManager. To apply a theme, install the corresponding Syncfusion theme NuGet package and call SfSkinManager.SetTheme in code-behind.
Required NuGet Package per Theme
| Theme Name | NuGet Package |
|---|---|
FluentLight | Syncfusion.Themes.FluentLight.WPF |
FluentDark | Syncfusion.Themes.FluentDark.WPF |
MaterialLight | Syncfusion.Themes.MaterialLight.WPF |
MaterialDark | Syncfusion.Themes.MaterialDark.WPF |
MaterialLight3 | Syncfusion.Themes.MaterialLight3.WPF |
MaterialDark3 | Syncfusion.Themes.MaterialDark3.WPF |
Office2019Colorful | Syncfusion.Themes.Office2019Colorful.WPF |
Office2019Black | Syncfusion.Themes.Office2019Black.WPF |
Office2019White | Syncfusion.Themes.Office2019White.WPF |
Office2019DarkGray | Syncfusion.Themes.Office2019DarkGray.WPF |
Windows11Light | Syncfusion.Themes.Windows11Light.WPF |
Windows11Dark | Syncfusion.Themes.Windows11Dark.WPF |
Note: Install only the NuGet package that matches the theme the user wants to apply.
Apply a Theme Using SfSkinManager in Code-Behind
The following example applies the FluentLight theme. Replace the theme name and NuGet package according to the desired theme from the table above.
Step 1: Install the theme NuGet package (example for FluentLight):
Install-Package Syncfusion.Themes.FluentLight.WPFStep 2: Add the SfSkinManager namespace to MainWindow.xaml:
<Window
x:Class="PdfViewerDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
xmlns:syncfusionskin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF">
<Grid x:Name="HomeGrid">
<syncfusion:PdfViewerControl x:Name="pdfViewer"></syncfusion:PdfViewerControl>
</Grid>
</Window>Step 3: Apply the theme in MainWindow.xaml.cs:
// Apply the FluentLight theme to PdfViewerControl.
// Replace "FluentLight" with your desired theme name (e.g., "FluentDark", "MaterialLight", "Windows11Light").
SfSkinManager.SetTheme(pdfViewer, new Theme() { ThemeName = "FluentLight" });
// Load a PDF after applying the theme.
pdfViewer.Load(@"customer.pdf");Placeholders
- Replace
"FluentLight"with the desired theme name from the table above. - Replace
customer.pdfwith the customer-given PDF file path. - Install the corresponding NuGet package for the chosen theme.
References
- Apply theme using SfSkinManager
- Create a custom theme using ThemeStudio
- WPF PdfViewer Getting Started – Theme
---
API Reference for All Load Methods, Properties, and Events
| API | Type | Description |
|---|---|---|
Load(filePath) | Method | Loads a PDF document from the given file path. |
Load(stream) | Method | Loads a PDF document from a Stream. |
Load(filePath, password) | Method | Loads a password-protected PDF from a file path. |
Load(stream, password) | Method | Loads a password-protected PDF from a Stream. |
LoadAsync(PdfLoadedDocument) | Method | Asynchronously loads a PDF from a PdfLoadedDocument. |
LoadAsync(Stream) | Method | Asynchronously loads a PDF from a Stream. |
LoadAsync(Stream, string) | Method | Asynchronously loads a password-protected PDF from a Stream. |
LoadAsync(string) | Method | Asynchronously loads a PDF from a file path. |
LoadAsync(string, string) | Method | Asynchronously loads a password-protected PDF from a file path. |
ItemSource | Property | Accepts a file path, Stream, or PdfLoadedDocument to load a PDF; supports XAML binding. |
Unload(bool) | Method | Unloads the document; pass true to also dispose it. |
GetDocumentPassword | Event | Fires when the viewer needs the document password; set e.Handled = true to suppress the built-in dialog. |
GetDocumentPasswordEventArgs.Password | Property | SecureString password to supply programmatically. |
GetDocumentPasswordEventArgs.Handled | Property | Set to true to hide the built-in password dialog. |
LoadingIndicator.LoaderColor | Property | Color of the loading spinner shown while the PDF is loading. |
LoadingIndicator.LoadingMessage | Property | Text message displayed in the loading indicator. |
SfSkinManager.SetTheme(control, theme) | Method | Applies a built-in theme to the PdfViewerControl using Syncfusion.SfSkinManager. |
Localization in WPF Pdf Viewer
Localization in the Syncfusion WPF PdfViewer allows configuring all static text (tooltips, context menus, toolbar labels, dialog messages) to a specific language by adding .resx resource files to the application. To localize the viewer, create a Resources folder in your project (new or existing), add the default English .resx file, and then add a culture-specific .resx file with translated values for the same keys. Set Thread.CurrentThread.CurrentUICulture before InitializeComponent() to activate the desired language at runtime.
Add a Resources Folder and Culture-Specific Resource Files to a New or Existing Project to Enable Localized Text in WPF PdfViewer
To localize the WPF PdfViewer, a Resources folder must exist in the project. If the project is newly created, add this folder manually. If the project already exists and does not have a Resources folder, add it in the same way. Inside this folder, place the default English resource file and a culture-specific resource file containing translated values for each key.
Steps: 1. In Solution Explorer, right-click the project → Add → New Folder → name it Resources. 2. Right-click the Resources folder → Add → New Item → select Resources File. 3. Name the default file Syncfusion.PdfViewer.WPF.resx and add it. This file holds the base (English) key-value pairs. 4. Add a second Resources File named Syncfusion.PdfViewer.WPF.[Culture].resx (e.g., Syncfusion.PdfViewer.WPF.fr.resx for French, Syncfusion.PdfViewer.WPF.de.resx for German). 5. In the culture-specific file, add the same resource keys as the default file but replace each value with the translated text for the target language. 6. Set the Access Modifier of both .resx files to Public in the resource editor.
Placeholders
- Replace
[Culture]with the target culture code (e.g.,frfor French,defor German,jafor Japanese).
Default English (en-US) Resource Keys and Values for Syncfusion WPF PdfViewer
The table below lists every localizable key used by the WPF PdfViewer along with its default English value. Copy these keys into your culture-specific .resx file and replace the values with translations for the target language.
| Key | Default Value (en-US) |
|---|---|
Accepted | Accepted |
AddLayer | Click to add a layer. |
AddReply | Add Reply |
AddSignatureLabel | Add signature |
AddStampMessage | Click to add stamp |
AddStickyNote | Add sticky note |
After | After |
Annotations | Show Annotations |
Appearance | Appearance |
ApplyLabel | Apply |
ApplyRedactionLabel | Apply |
ApplyRedactionMessage | Click to permanently remove marked content. |
Arrow | Arrow |
Author | Author |
BackgroundColor | Background color |
Before | Before |
BlankPageMessage | Blank page |
BlankPageText | Blank Page |
BookmarkNotExists | This bookmark destination doesn't exist |
BookmarkTitle | Bookmarks |
BorderColor | Border color |
BorderStyle | Border Style |
BorderThickness | Border thickness |
BrowseButtonHeaderText | Add Stamp |
Butt | Butt |
Cancel | Cancel |
Cancelled | Cancelled |
ClearLabel | Clear |
CloseAnnotationsToolbarMessage | Click to close annotations toolbar. |
CloseBookmark | Click to close the bookmark pane |
Closed | Closed |
CloseFontPopUp | Click to close the text properties |
CloseFormOptionsMessage | Close form options |
CloseLayer | Click to close the layer pane |
ClosePageOrganizerMessage | Click to close organize pages pane. |
CloseRedactionMessage | Close redact |
CloseSearchBar | Close Search Bar |
CloseThumbnail | Click to close the thumbnail pane |
Cloud | Cloud |
Color | Color |
ColorPicker | Color picker |
Comment | Comment |
Comments | Comments |
CommentsPanel | Comments Panel |
Completed | Completed |
ConfirmationBeforeClose | Do you want to save changes before closing? |
Copy | Copy |
CounterclockwiseMessage | Rotate counterclockwise |
CreateSignatureLabel | Create signature |
CurrentPageNumber | Current page index |
CustomStampHeaderText | Custom Stamps |
CustomTextLabel | Custom text |
CutMessage | Cut |
DecreaseMagnification | Click to decrease the magnification of the entire page. |
Delete | Delete |
DeleteLayer | Click to delete a layer |
DeletePagesConfirmation | Are you sure you want to delete the pages from the document? |
DeletePagesLimitation | You cannot delete all pages. At least one page should remain |
DeletePagesMesage | Delete pages |
Diamond | Diamond |
DocumentProtected | This document is protected. Please enter a document open password. |
DrawCircle | Circle |
DrawingTools | Drawing Tools |
DrawInk | Draw free form |
DrawLine | Line |
DrawPolygon | Polygon |
DrawPolyline | Polyline |
DrawRectangle | Rectangle |
DrawTextCallout | Text Callout |
Edit | Edit |
EnableMultiplePageSelection | Enable multiple page selection |
End | End |
EnlargePageThumbnails | Enlarge page thumbnails |
EnterPassword | Enter password |
Error | Error |
EssentialPdfViewer | Essential Pdf Viewer |
Export annotation to JSON file | Export annotation to JSON file |
Export annotation to XFDF file | Export annotation to XFDF file |
ExportDataMessage | Export data from a Form file |
FileAlreadyOpenedInformation | This file is already opened. Please close it before saving |
FilesViewMessage | Click to open, save and print a PDF Document |
FileText | File |
FillColor | Fill color |
FillOpacityLabel | Fill opacity |
FirstText | First |
FitPage | Fit to Page |
FitWidth | Fit to Width |
FontColorLabel | Font color |
FontLabel | Font |
FontSizeLabel | Font size |
FormDataLabel | Form Data |
FormDataMessage | Form Data |
FormExportLabel | Export |
FormImportLabel | Import |
FormNameRequestDialogTitle | File Name |
FormNameRequestText | Enter the name of the loaded PDF file |
FreeText | Free Text |
FreeTextBox | Add text box |
FreeTextProperties | Free text properties |
FromFileMessage | From file |
General | General |
GoToFirstPage | Click to go to first page in the document. |
GoToLastPage | Click to go to last page in the document. |
GoToNextPage | Click to go to next page in the document. |
GoToPreviousPage | Click to go to previous page in the document. |
HandwrittenSignatureMessage | Sign document by drawing a signature. |
HandwrittenSignaturePropertiesLabel | Handwritten signature properties |
Help | Help |
Highlight | Highlight |
HighlightProperties | Highlight properties |
HighlightText | Highlight text |
Icon | Icon |
Import annotation from JSON file | Import annotation from JSON file |
Import annotation from XFDF file | Import annotation from XFDF file |
ImportDataMessage | Import data into a Form file |
IncorrectNumericEntry | Invalid numeric value |
IncorrectPassword | Incorrect password |
IncreaseMagnification | Click to increase the magnification of the entire page. |
Information | Information |
Ink | Ink |
InkEraser | Click to erase a part of the ink annotation (freehand drawings) |
InkProperties | Ink properties |
InsertButtonText | Insert |
InsertPageMessage | Insert pages |
InsertPagesTitle | Insert Pages |
InsertPdfTitle | Select PDF to insert |
InsertText | Insert Text |
InsertTextBlock | Insert: |
InvalidPasswordError | Password is invalid |
Key | Key |
LastText | Last |
LayerTitle | Layers |
LineEnding | Line Ending |
LineProperties | Line properties |
LoadingPage | Loading Pages |
LocationText | Location |
Locked | Locked |
MakeDefault | Set as default |
MakePropertiesDefault | Make Properties default |
MarkForRedactionLabel | Mark for Redaction |
MarkForRedactionMessage | Click to mark content for permanent removal. |
MarqueeZoom | Zoom Select Area |
MatchCase | Match Case |
Message | Message |
Modified | Modified |
MoreActions | Click to view more actions |
NewParagraph | New Paragraph |
Next | Next |
NoMatchesFound | Reader has finished searching the document. No matches were found |
NoMoreMatchesFound | Reader has finished searching the document. No more matches were found |
None | None |
Note | Note |
Of | of |
OfText | of |
Ok | OK |
Opacity | Opacity |
Open | Open |
OpenDocument | Click to open a PDF Document |
OpenHeaderText | Open |
OpenPopupNote | Open Pop-up Note |
OutlineColorLabel | Outline color |
Oval | Oval |
OvalProperties | Oval properties |
OverlayTextTitleLabel | Overlay text |
Page | Page |
PageCount | Total page count |
PageGroupTitle | Page |
PageNotExists | There is no page numbered '{0}' in this document |
PageOrganizerTitle | Organize Pages |
PageText | Page: |
Panning | Click to pan around the document |
Paragraph | Paragraph |
PasswordCancelButton | Cancel |
PasswordOkButton | OK |
PasswordRequestDialogTitle | Password |
PasteMessage | Paste |
PolygonalLine | Polygonal Line |
PolygonLineProperties | Polygon line properties |
PolygonProperties | Polygon properties |
Post | Post |
Previous | Previous |
PrintDocument | Click to Print this PDF file or pages from it. |
PrintHeaderText | |
Properties | Properties |
RectangleProperties | Rectangle properties |
RedactedAreaFillLabel | Redacted area fill color |
RedactionConfirmation | Are you sure you want to continue? |
RedactionLabel | Redaction |
RedactionMarkAppearancelabel | Redaction mark appearance |
RedactionMessage | Click to perform redaction. |
RedactionPropertiesLabel | Redaction tool properties |
RedactionPropertiesMessage | Click to view redaction tool properties. |
RedactionWarning | You are about to permanently remove all content that has been marked for redaction. Once the document is saved, this operation cannot be undone |
ReducePageThumbnails | Reduce page thumbnails |
Rejected | Rejected |
Rename | Rename |
RequestCorrectPassword | Please open the document again and enter the correct password |
ReversedClose | Closed (Reverse) |
ReversedOpen | Open (Reverse) |
RotateClockwiseMessage | Rotate clockwise |
Round | Round |
SaveAsDocument | Click to save the document in the local disk |
SaveAsHeaderText | Save As |
SaveDocument | Click to save the document in the local disk |
SaveHeaderText | Save |
SearchIndicator | Searching |
SearchText | Click to search text |
SelectionTool | Selection tool for text |
SetStatus | Set Status |
Slash | Slash |
Square | Square |
Squiggly | Squiggly |
SquigglyProperties | Squiggly Properties |
Stamp | Stamp |
StampPropertiesLabel | Stamp properties |
StandardLabel | Standard Business |
Start | Start |
StickyNote | Sticky Note |
StickyNoteProperties | Sticky note properties |
StrikeoutProperties | Strikethrough properties |
StrikeoutText | Strikethrough text |
Strikethrough | Strikethrough |
Subject | Subject |
TextCalloutProperties | Text callout properties |
TextMarkupAnnotation | Text Markup Annotation |
TextProperties | Text properties |
Thickness | Thickness |
ThumbnailTitle | Page Thumbnails |
Underline | Underline |
UnderlineProperties | Underline properties |
UnderlineText | Underline text |
UseOverlayTextLabel | Use overlay text |
ValueExceedsLimit | The value must be between {0} and {1} |
ViewBookmarks | Click to view the bookmarks |
ViewLayers | Click to view the layers |
ViewPageOrganizerMessage | Rotate, rearrange, insert or delete pages |
ViewThumbnails | Click to view the thumbnails |
Warning | Warning |
ZoomLevel | Current zoom level |
Apply Localization by Setting the Thread UI Culture Before Initializing the Window in Code-Behind
Set Thread.CurrentThread.CurrentUICulture to the desired culture code before calling InitializeComponent(). This must be done before the window initializes so that the PdfViewer picks up the correct .resx file from the Resources folder. The culture-specific .resx file (e.g., Syncfusion.PdfViewer.WPF.fr.resx) must already be present in the Resources folder of the project with the translated key values.
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
InitializeComponent();
pdfViewer.Load(@"sample.pdf");Placeholders
- Replace
fr-FRwith the target culture code (e.g.,de-DEfor German,ja-JPfor Japanese,ar-SAfor Arabic). - Replace
sample.pdfwith the actual PDF file path.
Load Localized Resources from a Custom Assembly and Namespace Using LocalizationManager in Code-Behind
When the localization resource files are stored in a separate class library or a different assembly (not the main application project), use LocalizationManager.SetResources to point the PdfViewer to the correct assembly and namespace. Call this method after setting the UI culture and before InitializeComponent(). The Resources folder and the culture-specific .resx file must exist inside that external assembly under the specified namespace.
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
// Set custom assembly and namespace for localization
LocalizationManager.SetResources(typeof(CustomClass).Assembly, "ClassLibrary");
InitializeComponent();Placeholders
- Replace
CustomClasswith any class that belongs to the assembly containing the resource files. - Replace
ClassLibrarywith the root namespace of that assembly where theResourcesfolder is located. - Replace
fr-FRwith the desired culture code.
API Reference for All Localization Properties and Methods
| API | Type | Description |
|---|---|---|
Thread.CurrentThread.CurrentUICulture | Property | Sets the culture used to look up localized resources. Must be set before InitializeComponent(). |
LocalizationManager.SetResources(assembly, namespace) | Method | Registers a custom assembly and namespace for resource lookup when resource files are in a separate project. |
Magnifying PDF Documents in WPF Pdf Viewer
The Syncfusion WPF PdfViewer allows you to magnify PDF documents programmatically using zoom APIs, set zoom modes, define zoom percentage limits, and handle zoom change notifications.
Zoom the PDF Document to a Specific Percentage Using Code-Behind
// Zoom to 235 percentage
pdfViewer.ZoomTo(235);Get the Current Zoom Percentage of the Viewer Using Code-Behind
int currentZoomPercentage = pdfViewer.ZoomPercentage;Set the Zoom Mode to Fit Page or Fit Width Using Code-Behind
// Fit to page
pdfViewer.ZoomMode = ZoomMode.FitPage;
// Fit to width
pdfViewer.ZoomMode = ZoomMode.FitWidth;Define Minimum and Maximum Zoom Percentage Limits and Zoom to Maximum Using Code-Behind
// Set minimum zoom percentage (default: 50, range: 10 to MaximumZoomPercentage)
pdfViewer.MinimumZoomPercentage = 20;
// Set maximum zoom percentage (default: 400, range: MinimumZoomPercentage to 6400 for PDFium)
pdfViewer.MaximumZoomPercentage = 600;
// Zoom to max
pdfViewer.ZoomTo(pdfViewer.MaximumZoomPercentage);Zoom to a Specific Rectangular Area of the PDF Page
The ZoomToRect method allows you to zoom into a specific rectangular region of the currently displayed PDF page. This is useful for focusing on a particular area.
private void Button_Click(object sender, RoutedEventArgs e)
{
pdfViewer.ZoomToRect(new Rect(400, 50, 200, 150));
}Hide the Zoom Tools in the Toolbar Using Code-Behind
pdfViewer.ToolbarSettings.ShowZoomTools = false;Handle the ZoomChanged Event to Get the Updated Zoom Percentage Using Code-Behind
pdfViewer.ZoomChanged += PdfViewer_ZoomChanged;
pdfViewer.Load(@"sample.pdf");
private void PdfViewer_ZoomChanged(object sender, ZoomEventArgs args)
{
int currentZoomPercentage = args.ZoomPercentage;
}Placeholders
- Replace
sample.pdfwith the actual PDF file path.
API Reference for All Zoom Properties, Methods, and Events
| API | Type | Description |
|---|---|---|
ZoomTo(int) | Method | Magnifies the document to the specified zoom percentage. |
ZoomPercentage | Property | Gets the current zoom percentage of the viewer. |
ZoomMode | Property | Gets or sets the zoom mode (FitPage or FitWidth). |
MinimumZoomPercentage | Property | Gets or sets the minimum zoom percentage (default: 50). |
MaximumZoomPercentage | Property | Gets or sets the maximum zoom percentage (default: 400). |
ToolbarSettings.ShowZoomTools | Property | Shows or hides the zoom tools in the toolbar. |
ZoomChanged | Event | Fires when the zoom percentage changes. |
ZoomEventArgs.ZoomPercentage | Property | Gets the current zoom percentage from the event args. |
Navigation in WPF Pdf Viewer
Navigation support in the Syncfusion WPF PdfViewer enables page navigation, bookmark navigation, thumbnail navigation, hyperlink navigation, and table of contents (TOC) navigation.
Navigate to a Specific Page by One-Based Page Number Using Code-Behind
pdfViewer.GotoPage(2);Go to the First Page
Navigates the viewer to the very first page of the loaded PDF document.
pdfViewer.GoToFirstPage();Go to the Last Page
pdfViewer.GoToLastPage();Go to the Next Page
pdfViewer.GoToNextPage();Go to the Previous Page
pdfViewer.GoToPreviousPage();Navigate to a Specific Page by Zero-Based Index Using Code-Behind
pdfViewer.GoToPageAtIndex(2);Get the Total Number of Pages in the Loaded PDF Document Using Code-Behind
int pageCount = pdfViewer.PageCount;Get the Index of the Currently Displayed Page Using Code-Behind
int currentPage = pdfViewer.CurrentPageIndex;Navigate Using PdfDocumentView Navigation State Properties
The PdfDocumentView exposes several read-only boolean properties that indicate whether specific navigation actions are currently possible. These properties are typically used to enable or disable navigation buttons and to validate navigation commands, not to force navigation.
public bool CanGoToFirstPage { get; }
public bool CanGoToPreviousPage { get; }
public bool CanGoToNextPage { get; }
public bool CanGoToLastPage { get; }Property Descriptions
- CanGoToFirstPage – Returns true if navigation to the first page is possible (current page is not the first page).
- CanGoToPreviousPage – Returns true if navigation to the previous page is possible.
- CanGoToNextPage – Returns true if navigation to the next page is possible.
- CanGoToLastPage – Returns true if navigation to the last page is possible (current page is not the last page).
Example Usage
The navigation state properties are commonly used to safely navigate pages and control UI elements such as toolbar buttons.
Example: Safe Navigation Based on State
Each navigation call is executed only when the corresponding state indicates it is possible.
// Navigate to the first page only if not already on the first page
if (pdfDocumentView.CanGoToFirstPage)
{
pdfDocumentView.GoToFirstPage();
}
// Navigate to the previous page only if a previous page exists
if (pdfDocumentView.CanGoToPreviousPage)
{
pdfDocumentView.GoToPreviousPage();
}
// Navigate to the next page only if a next page exists
if (pdfDocumentView.CanGoToNextPage)
{
pdfDocumentView.GoToNextPage();
}
// Navigate to the last page only if not already on the last page
if (pdfDocumentView.CanGoToLastPage)
{
pdfDocumentView.GoToLastPage();
}Scroll the Document to a Specific Horizontal and Vertical Offset Using Code-Behind
// Scroll to horizontal offset 160 and vertical offset 400
pdfViewer.ScrollTo(160, 400);Scroll the Document Vertically Using ScrollTo(double)
// Scroll vertically to offset 400
pdfViewer.ScrollTo(400);Expand the Thumbnail Navigation Panel Programmatically on Window Load Using Code-Behind
pdfViewer.ThumbnailSettings.IsExpanded = true;Hide the Thumbnail Navigation Panel Programmatically on Window Load Using Code-Behind
// Hide the thumbnail panel
pdfViewer.ThumbnailSettings.IsVisible = false;Navigate to the First Bookmark After the Document Is Loaded Using Code-Behind
pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
{
PdfLoadedDocument pdfLoadedDocument = pdfViewer.LoadedDocument;
PdfBookmarkBase bookmarks = pdfLoadedDocument.Bookmarks;
// Navigate to the first bookmark
pdfViewer.GoToBookmark(bookmarks[0]);
}Navigate to a Child Bookmark of a Parent Bookmark Entry Using Code-Behind
PdfLoadedDocument pdfLoadedDocument = pdfViewer.LoadedDocument;
PdfBookmarkBase bookmarks = pdfLoadedDocument.Bookmarks;
PdfBookmark fourthBookmark = bookmarks[3];
if (fourthBookmark.Count > 0)
{
// Navigate to the first child of the fourth bookmark
pdfViewer.GoToBookmark(bookmarks[3][0]);
}Expand the Bookmark Navigation Panel Programmatically on Window Load Using Code-Behind
// Expand the bookmark panel
pdfViewer.BookmarkSettings.IsExpanded = true;
Disable the Bookmark Feature and Hide the Bookmark Button Using Code-Behind
pdfViewerControl.IsBookmarkEnabled = false;Display a Notification Bar in the Viewer
The InsertNotificationBar method allows you to display a message banner inside the PDF viewer. This is useful for showing informational messages, warnings, or status updates to users.
pdfViewer.InsertNotificationBar("This is a notification bar");Retrieve the URI of a Clicked Hyperlink by Handling the HyperlinkClicked Event Using Code-Behind
pdfViewerControl.HyperlinkClicked += PdfViewerControl_HyperlinkClicked;
private void PdfViewerControl_HyperlinkClicked(object sender, HyperlinkClickedEventArgs args)
{
// Retrieve the clicked URI
string uri = args.Uri;
}Prevent Default Browser Navigation When a Hyperlink Is Clicked Using Code-Behind
pdfViewerControl.HyperlinkClicked += PdfViewerControl_HyperlinkClicked;
private void PdfViewerControl_HyperlinkClicked(object sender, HyperlinkClickedEventArgs args)
{
// Prevent default navigation
args.Handled = true;
}Handle the Mouse-Over Event When the Pointer Moves Over a Hyperlink Using Code-Behind
pdfViewerControl.HyperlinkMouseOver += PdfViewerControl_HyperlinkMouseOver;
private void PdfViewerControl_HyperlinkMouseOver(object sender, EventArgs args)
{
// Handle mouse over hyperlink
}API Reference
| API | Type | Description |
|---|---|---|
GotoPage(pageIndex) | Method | Navigates to the specified page number. |
GoToPageAtIndex(int) | Method | Navigates to the specified zero-based page index. |
PageCount | Property | Gets the total number of pages in the loaded document. |
CurrentPageIndex | Property | Gets the index of the currently displayed page. |
ScrollTo(horizontalOffset, verticalOffset) | Method | Scrolls the document to the given horizontal and vertical offset. |
GoToBookmark(bookmark) | Method | Navigates to the specified bookmark destination. |
LoadedDocument | Property | Returns the PdfLoadedDocument object of the loaded PDF. |
IsBookmarkEnabled | Property | Enables or disables the bookmark feature and button. |
BookMarkSettings.IsExpanded | Property | Expands or collapses the bookmark panel programmatically. |
ThumbnailSettings.IsExpanded | Property | Expands or collapses the thumbnail panel programmatically. |
ThumbnailSettings.IsVisible | Property | Shows or hides the thumbnail panel. |
HyperlinkClicked | Event | Fires when a hyperlink in the PDF is clicked. |
HyperlinkMouseOver | Event | Fires when the mouse pointer moves over a hyperlink. |
HyperlinkClickedEventArgs.Uri | Property | Returns the URI of the clicked hyperlink. |
HyperlinkClickedEventArgs.Handled | Property | Set to true to prevent default hyperlink navigation. |
DocumentLoaded | Event | Fires when the PDF document is fully loaded. |
GoToFirstPage() | Method | Navigates to the first page of the document. |
GoToLastPage() | Method | Navigates to the last page of the document. |
GoToNextPage() | Method | Navigates to the next page relative to the current page. |
GoToPreviousPage() | Method | Navigates to the previous page relative to the current page. |
Organize Pages in WPF Pdf Viewer
Organize pages support in the Syncfusion WPF PdfViewer allows you to rotate, rearrange, insert, and delete pages from a PDF document using PageOrganizer and PageOrganizerSettings.
Rotate One or More Pages to a Specific Angle Using Code-Behind
// Rotate pages at index 0 and 1 to 90 degrees
pdfViewer.PageOrganizer.Rotate(new int[] { 0, 1 }, Syncfusion.Pdf.PdfPageRotateAngle.RotateAngle90);Placeholders
- Replace
0, 1with the target zero-based page indexes. - Replace
RotateAngle90withRotateAngle180orRotateAngle270as needed.
Rotate One or More Pages 90 Degrees Clockwise Using Code-Behind
pdfViewer.PageOrganizer.RotateClockwise(new int[] { 0, 1 });Rotate One or More Pages 90 Degrees Counterclockwise Using Code-Behind
pdfViewer.PageOrganizer.RotateCounterclockwise(new int[] { 0, 1 });Get the Current Rotation Angle of a Specific Page by Zero-Based Index Using Code-Behind
PdfPageRotateAngle rotatedAngle = pdfViewer.PageOrganizer.GetPageRotation(0);Placeholders
- Replace
0with the target zero-based page index.
Rearrange All Pages in a Custom Order by Providing Zero-Based Indexes Using Code-Behind
// Rearrange pages — swaps page 0 and page 1
pdfViewer.PageOrganizer.ReArrange(new int[] { 1, 0 });Placeholders
- Provide all page indexes in the desired order. Any index omitted will be removed.
Remove a Single Page by Zero-Based Index Using Code-Behind
pdfViewer.PageOrganizer.RemoveAt(0);Remove Multiple Pages by Zero-Based Indexes Using Code-Behind
pdfViewer.PageOrganizer.RemovePages(new int[] { 0, 1 });Placeholders
- Replace
0, 1with the target zero-based page indexes to remove.
Handle the PageSelected Event to Retrieve Selected Page Indexes from the Organizer Panel
pdfViewer.PageSelected += PdfViewer_PageSelected;
private void PdfViewer_PageSelected(object sender, PageSelectedEventArgs e)
{
if (e.SelectedPages.Length != 0)
{
int[] selectedPages = e.SelectedPages;
}
}Placeholders
- Replace
sample.pdfwith the actual PDF file path.
Hide the Page Organizer Icon from the Left Pane Using Code-Behind
pdfViewer.PageOrganizerSettings.IsIconVisible = false;Show Annotations and Form Fields in the Page Organizer Panel Using Code-Behind
pdfViewer.PageOrganizerSettings.ShowAnnotations = true;API Reference for All PageOrganizer Methods, Commands, Events, and Settings Properties
| API | Type | Description |
|---|---|---|
PageOrganizer.Rotate(pageIndexes, angle) | Method | Rotates the specified pages to the given PdfPageRotateAngle. |
PageOrganizer.RotateClockwise(pageIndexes) | Method | Rotates the specified pages 90 degrees clockwise. |
PageOrganizer.RotateCounterclockwise(pageIndexes) | Method | Rotates the specified pages 90 degrees counterclockwise. |
PageOrganizer.RotatePagesCommand | Command | Rotates pages to a specific angle via command. |
PageOrganizer.RotatePagesClockwiseCommand | Command | Rotates pages clockwise via command. |
PageOrganizer.RotatePagesCounterclockwiseCommand | Command | Rotates pages counterclockwise via command. |
PageOrganizer.GetPageRotation(pageIndex) | Method | Returns the current PdfPageRotateAngle of the specified page. |
PageOrganizer.ReArrange(pageIndexes) | Method | Rearranges pages in the specified order (zero-based). |
PageOrganizer.RemoveAt(pageIndex) | Method | Removes the page at the specified zero-based index. |
PageOrganizer.RemovePages(pageIndexes) | Method | Removes the pages at the specified zero-based indexes. |
PageOrganizer.RemovePagesCommand | Command | Removes pages via command with page indexes as parameter. |
PdfViewerControl.PageSelected | Event | Fires when page(s) are selected in the organize pages panel. |
PageSelectedEventArgs.SelectedPages | Property | Array of zero-based indexes of the currently selected pages. |
PageOrganizerSettings.IsIconVisible | Property | Shows or hides the page organizer icon in the left pane. |
PageOrganizerSettings.ShowAnnotations | Property | Shows or hides annotations and form fields in the organizer panel. |
PDF Coordinates in WPF Pdf Viewer
The Syncfusion WPF PdfViewer allows converting between client coordinates and PDF page coordinates, retrieving scroll offsets, and bringing a specific region into view.
Get the Bounding Rectangle of the PDF Viewer's Client Area (Viewport) Using Code-Behind
Rectangle clientRectangle = pdfViewerControl.ClientRectangle;Get the Current Horizontal and Vertical Scroll Offsets and Scroll to a New Position Using Code-Behind
double horizontalOffset = pdfViewerControl.HorizontalOffset;
double verticalOffset = pdfViewerControl.VerticalOffset;
pdfViewerControl.ScrollTo(horizontalOffset + 10, verticalOffset + 10);Convert a Client Coordinate Point to a PDF Page Coordinate Point on Page Click Using Code-Behind
private void PdfViewerControl_PageClicked(object sender, PageClickedEventArgs e)
{
Point clientPoint = e.Position;
int pageNumber = pdfViewerControl.GetPageNumberFromClientPoint(clientPoint);
Point pagePoint = pdfViewerControl.ConvertClientPointToPagePoint(clientPoint, pageNumber);
}Convert a PDF Page Coordinate Point to a Client Coordinate Point on Annotation Change Using Code-Behind
private void PdfViewer_ShapeAnnotationChanged(object sender, ShapeAnnotationChangedEventArgs e)
{
RectangleF bounds = e.OldBounds;
Point pagePoint = new Point(bounds.X, bounds.Y);
int pageNumber = e.PageNumber;
Point clientPoint = pdfViewerControl.ConvertPagePointToClientPoint(pagePoint, pageNumber);
}Convert a PDF Page Coordinate Point to a Scroll Coordinate Point on Annotation Change Using Code-Behind
private void PdfViewer_ShapeAnnotationChanged(object sender, ShapeAnnotationChangedEventArgs e)
{
RectangleF bounds = e.OldBounds;
Point pagePoint = new Point(bounds.X, bounds.Y);
int pageNumber = e.PageNumber;
Point scrollPoint = pdfViewerControl.ConvertPagePointToScrollPoint(pagePoint, pageNumber);
}Bring a Specific Client-Coordinate Rectangle into View and Zoom to Fit It Using Code-Behind
Rect bounds = new Rect(400, 300, 200, 400);
pdfViewerControl.ZoomToRect(bounds);API Reference for All Coordinate Conversion Properties and Methods
| API | Type | Description |
|---|---|---|
ClientRectangle | Property | Gets the bounding rectangle of the PDF Viewer's client area (viewport). |
HorizontalOffset | Property | Gets the current horizontal scroll offset. |
VerticalOffset | Property | Gets the current vertical scroll offset. |
ScrollTo(horizontalOffset, verticalOffset) | Method | Scrolls the content to the specified horizontal and vertical offset. |
GetPageNumberFromClientPoint(clientPoint) | Method | Returns the page number corresponding to a client area point. |
ConvertClientPointToPagePoint(clientPoint, pageNumber) | Method | Converts a client coordinate point to a PDF page coordinate point. |
ConvertPagePointToClientPoint(pagePoint, pageNumber) | Method | Converts a PDF page coordinate point to a client coordinate point. |
ConvertPagePointToScrollPoint(pagePoint, pageNumber) | Method | Converts a PDF page coordinate point to a scroll coordinate point. |
ZoomToRect(bounds) | Method | Brings the specified client-coordinate rectangle into view and zooms to fit it. |
PDF Rendering Engines in WPF Pdf Viewer
The Syncfusion WPF PDF Viewer supports two rendering engines to display PDF pages: PDFium (default since v16.3.0.x) and SfPdf (Syncfusion's own engine).
Use PDFium as the Default Rendering Engine Without Any Code Change
PDFium is the default rendering engine based on Google Chrome's PDF renderer, used automatically without any code change.
Set a Custom Writable Folder Path for PDFium Binary Extraction Using the ReferencePath Property
Sets a custom writable folder path using the ReferencePath property so PDFium binaries can be extracted there when the output folder has access restrictions.
// Set a custom writable path for PDFium extraction.
pdfViewer.ReferencePath = @"D:\ThirdPartyBinaries\";
pdfViewer.Load("Sample.pdf");
Placeholders
- Replace
D:\ThirdPartyBinaries\with the actual writable folder path on the target machine. - Replace
Sample.pdfwith the actual PDF file path or name.
Switch the Rendering Engine to SfPdf by Setting the RenderingEngine Property When PDFium Is Not Compatible
Switches the rendering engine to SfPdf by setting the RenderingEngine property, used when PDFium is not compatible with the environment.
// Switch rendering engine to SfPdf.
pdfViewer.RenderingEngine = PdfRenderingEngine.SfPdf;
pdfViewer.Load("Sample.pdf");Placeholders
Replace Sample.pdf with the actual PDF file path or name.
Text Extraction Engines in WPF Pdf Viewer
The Syncfusion WPF PDF Viewer supports two text extraction engines for text search, text selection, and text markup: PDFium (default since v19.4.0.48) and SfPdf (Syncfusion's own engine).
Use PDFium as the Default Text Extraction Engine for Improved Performance Without Any Code Change
PDFium is the default text extraction engine for improved performance, used automatically without any code change.
Switch the Text Extraction Engine to SfPdf (Legacy Engine) Using the TextExtractionEngine Property in Code-Behind
Switches the text extraction engine to SfPdf by setting the TextExtractionEngine property, used to fall back to Syncfusion's own engine.
// Switch text extraction engine to SfPdf (legacy engine).
pdfViewer.TextExtractionEngine = PdfTextExtractionEngine.SfPdf;
pdfViewer.Load("Sample.pdf");Placeholders
Replace Sample.pdf with the actual PDF file path or name.