PDF Export

The Grid provides options for exporting its content to PDF. To enable the PDF export, import the PDFModule and add the kendo-grid-pdf component to the Kendo UI Grid for Angular. To initiate the PDF export, use the kendoGridPDFCommand directive or the saveAsPDF method.

Change Theme

Configuration

Exporting All Pages

By default, the Grid exports only the current page of data. To export all pages, set the allPages option to true . When you enable the option, the pageChange event fires with skip set to 0 and take to the total number of records. The original skip and take are restored after the export completes.

Change Theme

Fitting Content to Paper Size

By default, the paper size of the exported document is determined by the size of the Grid on the screen. However, you can define a specific paper size that will apply to the whole document. As a result, the content is scaled to fit the specified paper size. It is possible to override the automatic scale factor—for example, to make room for additional page elements.

To use the whole space that is available, the Grid:

Change Theme

Customizing Exported Columns

The Grid enables you to specify the columns that will be exported. To configure them, include the and components inside the component.

Change Theme

Specifying Page Template

The Grid enables you to specify a page template that helps you position the content and add headers, footers, and other elements. To style the exported document, use the built-in kendoGridPDFTemplate and apply the necessary CSS styles. During the PDF export, the template is positioned in a container with the specified paper size.

When using the template, you are required to set the paperSize option.

The following example demonstrates how you can add headers and footers to the exported PDF file using the built-in kendoGridPDFTemplate .

Change Theme

Exporting Multiple Grids to the Same PDF

By default, the each Grid is exported to a separate document.

To export multiple Grids to the same document:

  1. Use the drawPDF method to get the group of Grids for export.
  2. Set the exportPDF method to export the group.
Change Theme

Triggering Export Externally

The Grid enables you to trigger the export operation by calling the saveAsPDF method.

Change Theme

Exporting Groups of Rows to Separate Pages

You can manually split the exported data into separate pages by using the forcePageBreak option of the PDFComponent .

  1. Sort the data by the respective field.
  2. By utilizing the rowClass function, add the class that will be used by the forceBreakPage option to the first row of each items group.

The following example demonstrates how to render all items with the same Category name to a separate PDF page.

Change Theme

Saving PDF Files

Internet Explorer 9 and Safari do not support the option for saving the exported PDF file and require the implementation of a server proxy. To specify the server proxy URL, set the proxyURL option.

Your project might require you to send the generated PDF file to a remote service. To achieve this behavior, set the proxyUrl and forceProxy to true . If the proxy returns 204 No Content , the Save As. dialog will not appear on the client.

Embedding Custom Fonts

The default fonts in the PDF files do not provide Unicode support. To render international characters, you need to embed an external font. For more information, refer to the article on custom fonts and PDF export.

In the following example, the DejaVu Sans font is loaded and applied to the exported PDF document.