Skip to end of metadata
Go to start of metadata

This example shows how use a custom paginator which is applied when printing a FlowDocument. In this example, FlowDocument is hosted in a UXFlowDocumentViewer control. However, you can specify a custom paginator in FlowDocument regardless of the viewer.



PrintDocument class will use the Print method to print the document. Print method needs two parameters, DocumentPaginator object and the document name. DocumentPaginator is an abstract base class that supports creation of multiple-page elements from a single document. By default, each FlowDocument has DocumentPaginator property that contain DocumentPaginator object for the flow document.

When FlowDocument is in page mode, the document content will flow according to the specified page configuration. If FlowDocument is in scroll mode, the document content will flow according to the available view port. In Silverlight application, you can choose a page size in the Print dialog window. In this case, the DocumentPaginator will create multiple page elements, despite of whether the FlowDocument is in page mode or scroll mode, for printing purpose with the selected page size. Unlike Silverlight applications, the selected page size in the Print dialog window is not used in WPF application. If you need to specify different page size for printing purpose, you can specify the page size in the custom paginator definition. You can also specify a custom paginator class to add custom elements for printing purpose only, such as header or footer.

The following code shows how to add header and footer element in a FlowDocument for printing purpose.


Custom Paginator Class