PDF Export

The UI for ASP.NET MVC TreeList HtmlHelper provides a built-in PDF export functionality.

For a runnable example, refer to the demo on exporting the TreeList to PDF.

Getting Started

To enable PDF export:

  1. Include the corresponding toolbar command and set the export settings.
  2. Include the Pako Deflate library in the page to enable compression.

To initiate the PDF export, press the Toolbar button or use the TreeList client-side API and call the saveAsPDF method.

The following example demonstrates how to enable the PDF export functionality of the TreeList.

    <!-- Load Pako Deflate library to enable PDF compression -->
    <script src="https://kendo.cdn.telerik.com/2020.3.1021/js/pako_deflate.min.js"></script>

        .Toolbar(tools => tools.Pdf())
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("All", "EmployeeDirectory"))

Embedding Unicode Characters

The default fonts in PDF files do not provide Unicode support. To support international characters, you have to embed an external font. For more information on the supported Deja Vu font family as part of the Kendo UI distributions and other fonts, refer to the Kendo UI for jQuery article on custom fonts and PDF.

The following example demonstrates how to handle custom fonts.

            Use the DejaVu Sans font for display and embedding in the PDF file.
            The standard PDF fonts have no support for Unicode characters.
        .k-treelist {
            font-family: "DejaVu Sans", "Arial", sans-serif;

        // Import the DejaVu Sans font for embedding.
        // NOTE: Only required if the Kendo UI stylesheets are loaded
        // from a different origin, for example, kendo.cdn.telerik.com.
            "DejaVu Sans"             : "https://kendo.cdn.telerik.com/2020.3.1021    /styles/fonts/DejaVu/DejaVuSans.ttf",
            "DejaVu Sans|Bold"        : "https://kendo.cdn.telerik.com/2020.3.1021    /styles/fonts/DejaVu/DejaVuSans-Bold.ttf",
            "DejaVu Sans|Bold|Italic" : "https://kendo.cdn.telerik.com/2020.3.1021    /styles/fonts/DejaVu/DejaVuSans-Oblique.ttf",
            "DejaVu Sans|Italic"      : "https://kendo.cdn.telerik.com/2020.3.1021    /styles/fonts/DejaVu/DejaVuSans-Oblique.ttf"

    <!-- Load Pako ZLIB library to enable PDF compression -->
    <script src="//kendo.cdn.telerik.com/2020.3.1021/js/pako_deflate.min.js"></script>

        .Toolbar(tools => tools.Pdf())
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("All", "EmployeeDirectory"))

See Also

In this article
Not finding the help you need? Improve this article