Multi-Page Content

The Drawing library enables you to generate multi-page content in PDF, prevent the page-split, and render page templates.

For more information on how to render multi-page content with the PDF Processing component, refer to its documentation.

Rendering Multi-Page Content

To render a multi-page PDF file, set multiPage: true to the Group object that you pass to exportPDF (master group). As a result, the group contains only Group shapes—one shape for each page (page groups). If the page group does not override the PDF options that you pass to the master group, the PDF options are applied to each page group.

The available options that can be overwritten are:

If the paperSize option for the master group is set to "auto" and the page groups do not override it, the paper size for each individual page is determined by its corresponding group. This means that the pages of the final document might be of different sizes.

Manual Page Breaking

To manually specify the page breaks, use the drawDOM method which allows you to create multi-page PDF content. As a result, a page break, which matches the forcePageBreak CSS selector, occurs before each element.

import { drawDOM, exportPDF, DrawOptions, Group } from '@progress/kendo-drawing';
import { saveAs } from '@progress/kendo-file-saver';

export function exportElement(element, options) {
    drawDOM(element, options).then((group) => {
        return exportPDF(group);
    }).then((dataUri) => {
        saveAs(dataUri, 'export.pdf');
    });
}

Automatic Page Breaking

The drawDOM method supports automatic page breaking. To automatically implement the page breaks, set the paperSize and margin options. You will still be able to apply the forcePageBreak configuration to manually specify the break points.

For more information, refer to the known limitations of the Drawing library and the PDF Export component.

import { drawDOM, exportPDF, DrawOptions, Group } from '@progress/kendo-drawing';
import { saveAs } from '@progress/kendo-file-saver';

export function exportElement(element, options) {
    drawDOM(element, options).then((group) => {
        return exportPDF(group);
    }).then((dataUri) => {
        saveAs(dataUri, 'export.pdf');
    });
}

Page Templates

When you request multi-page output through the forcePageBreak or paperSize options, you can additionally specify a page template. The page template is inserted into each page before the output is produced and you can position it relatively to the page by using CSS. The template has to be a function which receives the number of the current page (pageNum) and the total number of pages (totalPages).

import { drawDOM, exportPDF, DrawOptions, Group } from '@progress/kendo-drawing';
import { saveAs } from '@progress/kendo-file-saver';

export function exportElement(element, options) {
    drawDOM(element, options).then((group) => {
        return exportPDF(group);
    }).then((dataUri) => {
        saveAs(dataUri, 'export.pdf');
    });
}

Preventing Page Breaking in Elements

To prevent specific elements from being split across pages, use the keepTogether option. keepTogether accepts CSS selectors that are passable to querySelector.

All elements from the following example which have the "prevent-split" CSS class are kept within the boundaries of the pages and their content is not split. If they fall on a margin, they will be moved to the next page.

import { drawDOM, exportPDF, DrawOptions, Group } from '@progress/kendo-drawing';
import { saveAs } from '@progress/kendo-file-saver';

export function exportElement(element, options) {
    drawDOM(element, options).then((group) => {
        return exportPDF(group);
    }).then((dataUri) => {
        saveAs(dataUri, 'export.pdf');
    });
}
 /