Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Collapse]PDF Viewer
   [Expand]Getting Started
   [Expand]Interactive Forms
   [Expand]Navigation
   [Expand]Interactivity
    Deployment
   [Collapse]Examples
     How to: Add a PDF Viewer at Design Time
     How to: Add a PDF Viewer via Code
     How to: Load a PDF Document from a File
     How to: Load a PDF Document from a Stream
     How to: Determine the Page Number of a Clicked PDF Page
     How to: Determine the PDF Content Type Corresponding to a Specific Document Area
     How to: Use the PDF Printer Settings
     How to: Export AcroForm Data to XML
     How to: Import AcroForm Data from XML
     How to: Create a Text Markup Annotation and Specify its Properties
     How to: Replace Standard PDF Viewer Control Command with your own Custom Command
     How to: Custom Draw in the PDF Viewer
     How to: Add a Custom Bar Button Item to the Popup Menu
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Replace Standard PDF Viewer Control Command with your own Custom Command

Show Me

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

This example shows how to modify the functionality of an existing PdfViewer command.

The PdfViewer exposes the IPdfViewerCommandFactoryService interface that enables you to substitute the default command with your own custom command.

To accomplish this task:

  • Create a custom command class (e.g., a CustomNextPageCommand class), inherited from the command that you wish to replace (e.g., PdfNextPageCommand).
  • Override the required method of the command. The main functionality and command specifics are located in the Execute method.
  • Create a class (e.g., CustomPdfViewerCommandFactoryService) implementing the IPdfViewerCommandFactoryService. You should override the IPdfViewerCommandFactoryService.CreateCommand method to create an instance of a custom command class if an identifier of a certain command is passed as a parameter. So, instead of the default command, a custom command will be used by the PdfViewer.
  • Use the created class to substitute for the default PdfViewer's service.

How would you rate this topic?​​​​​​​