.NET, WinForms, PDF Viewer
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


How to replace standard PDF Viewer control command with your own custom command

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

The PDF Viewer 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 is located in the Execute method.
- Create a class (e.g., CustomPdfViewerCommandFactoryService) implementing the IPdfViewerCommandFactoryService. You should override the 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 the default PdfViewer’s service.