The DocumentViewer is the main class used by the document viewer. It is not a control itself: instead, it uses the UI controls of the parent containers.
Using the native UI controls of the parent containers allows the Document Viewer to:
The following figure shows an application that uses the document viewer:
The DocumentViewer has the following parts:
View (optional): Where the main content of the document is viewed.
Thumbnails (optional): Where the thumbnails of the pages are viewed.
Bookmarks (optional): Where the bookmarks and table of contents of the document is viewed.
Annotations (optional): Where the annotations toolbar and objects list is added.
Application User Interface: The UI elements of the user application - these are not part of the document viewer. These elements are typically standard menu and toolbar items that are tied to DocumentViewerCommands.
Perform the following steps to create a new DocumentViewer in your application:
Create a new instance of DocumentViewerCreateOptions and initialize the following members:
ThumbnailsContainer: (optional): Set to an existing control in your application. This is where the thumbnails is created (part 2). The document viewer will create an instance of ImageViewer and add it here.
BookmarksContainer: (optional): Set to an existing control in your application. This is where the bookmarks and table of contents is created (part 3). The document viewer will create a tree control and add it here.
UseAnnotations: (optional): Set to true or false to use annotations in the document viewer. The annotation toolbar and automation objects are created at a later time.
Call DocumentViewerFactory.CreateDocumentViewer, passing the create options from the previous step.
After a LEADDocument object is obtained, set it in the document viewer by calling the SetDocument method. The viewer will load the document and populate the view with raster or SVG representations of the pages. Any thumbnails, bookmarks, or annotations are populated by the document viewer as well.
If the LEADDocument being set in the viewer is not read-only, then the viewer will be notified when the Pages collection changes as a result of the user adding or removing pages from the document and it will update the view, thumbnail, annotations, text, and bookmarks parts accordingly. If multiple pages (from multiple documents even) are to be added or removed from the viewer, then it is best to surround the code with DocumentViewer.BeginUpdate and DocumentViewer.EndUpdate to minimize flickering while the viewer updates its parts.
The Document Viewer has support for client-side PDF rendering to enhance performance and reliability when viewing PDF documents and reduces server load. Client-side PDF rendering is enabled by default and can be toggled with the DocumentViewer.UsePDFRendering property. In this mode, the document viewer will check if the source document contains any PDF pages, and if so, will not use image/SVG rendering: instead, it will render the PDF image data for the page directly on the image viewer and thumbnail surface.
Refer to DocumentViewer.Print for more information.
For an example, refer to DocumentViewer. This example will show how to create a functional
DocumentViewer in your application.