The Drawing library enables you to generate multi-page content in PDF, prevent the page-split, and render page templates.
- Rendering multi-page content
- Manual page breaking
- Automatic page breaking
- Page templates
- Preventing page breaking in elements
For more information on how to render multi-page content with the PDF Export 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:
paperSizeoption 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.
Automatic Page Breaking
drawDOM method supports automatic page breaking. To automatically implement the page breaks, set the
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.
When you request multi-page output through the
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 (
Preventing Page Breaking in Elements
To prevent specific elements from being split across pages, use the
keepTogether accepts CSS selectors that are passable to
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.