Export to PDF
RadPivotGrid can export its contents to PDF. This is achieved with the help of the RadPdfProcessing library.
Figure 1: RadPivotGrid to PDF
The PDF export functionality is located in the TelerikExport.dll assembly and to use the functionality you need yo add reference to it.
Execute the Exporter
Before exporting to PDF, you have to initialize the PivotGridPdfExport class. The constructor takes one parameter - RadPivotGrid which will be exported. You need to create PdfExportRenderer instance as well:
PivotGridPdfExport Class
The RunExport method has several overloads allowing the user to export using a stream as well:
Running Export Synchronously Using a Stream
Properties
ExportVisualSettings: Gets or sets a value indicating whether the visual settings should be exported.
ExportSelectionOnly: Gets or sets a value indicating whether to export only selection.
ExportFlatData: Gets or sets a value which indicates whether to export flat data (collapsed rows and columns).
PageSize: Gets or sets the page size in millimeters.
PageMargins: Gets or sets the margins of pages in millimeters.
FitToPageWidth: Gets or sets a value indicating whether the content of page should fit into the page width.
Scale: Gets or sets the document scaling. Default value is 1. For example, scale of 1.2f means 20% size increase.
ShowHeaderAndFooter: Gets or sets a value indicating whether header and footer should be exported.
ExportSettings: This property allows you to set the document information.
The following properties define color and font of the different cell elements: CellBackColor, HeadersBackColor, DescriptorsBackColor, SubTotalsBackColor, GrandTotalsBackColor, BorderColor, HeaderCellsFont, DataCellsFont
Events
The PivotGridPdfExport exposes tree events that allows you to change the exported document.
CellFormatting: This event is fired for every exported cell. It allows you to change the cells properties including its value.
CellPaint: Occurs after a cell is drawn. This event allows you to draw additional elements to the cell.
PdfExported: Occurs when the export process completes.
The PdfExportRenderer is exposing two events as well. Detailed information is available here: PdfExportRenderer
Asynchronous Exporting
The PivotGrid can be exported asynchronously as well. The following example shows how you can run the exporter asynchronously.
Running Export Asynchronously
The RunExportAsync method has several overloads allowing the user to export using a stream as well:
Running Export Asynchronously Overloads
There are two events that can be used with the asynchronous export:
AsyncExportCompleted: Occurs when an asynchronous export operation is completed.
AsyncExportProgressChanged: Occurs when the progress of an asynchronous export operation changes.