Document Preview
- 3 minutes to read
This topic describes the DocumentPreviewControl that is used to display an interactive document preview in WPF applications.
The topic consists of the following sections.
Overview
The Document Preview displays document data provided by a document source of one of the following supported document source types.
- An object implementing the IReport interface.
- An object implementing the ILink interface.
- A Stream containing report document data.
- A string containing a path to a file that stores report document data (a PRNX file).
When a document is created, it is shown in the Document Preview.
Invoke the Document Preview
To show a document in a Document Preview, use one of the following approaches.
- Call the corresponding methods of the PrintHelper class or create a DocumentPreviewWindow instance. In these cases, only the default Document Preview is shown.
Add the DocumentPreviewControl to your application and associate it with the required document.
In this case, you can fully customize the Document Preview, which is demonstrated in the following tutorial: Customizing the Document Preview Toolbar.
For more details, see Document Preview.
Main Features
Toolbar
The Document Preview can include a toolbar and menu that contain buttons used to view, navigate, edit, print and export a document. The following two toolbar types are supported.
Each toolbar button triggers a specific command. For example, clicking the Page Setup… button triggers the DocumentPreviewControl.PageSetupCommand and invokes the Page Setup dialog, which is shown in the following image.
Document Map Panel
If a document contains bookmarks, the Document Map panel becomes available and allows you to quickly navigate through the document.
Parameters Panel
If a report has visible parameters, the corresponding button that defines the visibility of the Parameters panel becomes available. The Parameters user interface allows you to modify parameter values and update the document accordingly.
Thumbnails Panel
The Thumbnails toolbar button changes the visibility of report thumbnails used to quickly navigate between document pages.
Search Panel
To search for a specific text throughout a document, invoke the dedicated Search panel by clicking the Search toolbar button.
Interactivity
Content Editing
If content editing is enabled for document elements, it is possible to customize the corresponding field values in the Document Preview (clicking a field will invoke an appropriate editor). To highlight all editing fields available in a document, click the Editing Fields toolbar button.
Drill-Down Reports
You can add the drill-down functionality to a report to display data partially. Hidden data can be accessed in the Document Preview by clicking the designated element.
Document Preview Mouse Events
You can provide interactivity to reports shown in a Document Preview using the Preview’s mouse events (e.g., to create drill-through reports or enable data sorting directly in the preview).
- DocumentPreviewControl.DocumentPreviewMouseClick
- DocumentPreviewControl.DocumentPreviewMouseDoubleClick
- DocumentPreviewControl.DocumentPreviewMouseMove
For code samples, see the following examples online.
- How to create a drill-through report in WPF <!– OOM-Example
- How to sort a report in Document Preview for WPF –>
Customization
To learn how to customize the Document Preview, see the following tutorials:
- Customizing the Document Preview Toolbar
- Overriding Document Preview Commands
- Providing Custom Editors for Report Parameters