Skip to content

Commit 95c1ab7

Browse files
committed
Document forcePageBreak option in drawing.drawDOM
1 parent 6a793f7 commit 95c1ab7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

framework/drawing/drawing-dom.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ You can draw it from JavaScript with the following call:
3131

3232
`drawing.drawDOM` takes a jQuery selector or object, or a plain DOM node, and returns a promise which will deliver a `drawing.Group` object.
3333

34+
3435
### Custom fonts and PDF
3536

3637
If you need PDF output, for optimal layout and Unicode support your document should declare the fonts that it uses using [CSS `font-face` declarations](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face). Starting with version Q3-2014-SP1, the PDF generator in Kendo UI is able to dig such declarations directly from the CSS and there is no need for you to manually call [pdf.defineFont](/framework/drawing/pdf-output.html#using-custom-fonts).
@@ -56,6 +57,40 @@ Notes:
5657

5758
- Kendo UI bundles the DejaVu font family and will fall back to it for a few names like “Times New Roman”, “Arial”, “Courier”, or generics like “serif”, “sans-serif”, “monospace”, if no alternate fonts are specified. This is so that Unicode works by default. Note, however, that the layout problem will remain — the PDF output will be slightly different from the browser unless the exact same fonts are used.
5859

60+
61+
### Multi-page PDF output
62+
63+
`drawing.drawDOM` allows you to create a [multi-page PDF](/framework/drawing/pdf-output.html#multiple-pages-output) by specifying manual page breaks (automatic page breaking is not supported). For this, pass a second options argument which contains `forcePageBreak` — a CSS selector. Here is an example which draws a grid on a multi-page PDF:
64+
65+
<div id="grid"></div>
66+
67+
<script>
68+
var data = [];
69+
for (var i = 1; i < 50; ++i) {
70+
data.push({ title: "Item " + i, id: i });
71+
}
72+
73+
$("#grid").kendoGrid({
74+
dataSource: data,
75+
rowTemplate: $("#rowTemplate").html()
76+
});
77+
78+
kendo.drawing
79+
.drawDOM("#grid", { forcePageBreak: ".page-break" })
80+
.then(function(group){
81+
drawing.pdf.saveAs(group, "multipage.pdf")
82+
});
83+
</script>
84+
85+
<script id="rowTemplate" type="x/kendo-template">
86+
<!-- to every tenth row we add the "page-break" class -->
87+
<tr data-uid="#= uid #" class="#= (id%10 == 0 ? 'page-break' : '') #">
88+
<td>#: title #</td>
89+
<td>#: id #</td>
90+
</tr>
91+
</script>
92+
93+
5994
### Known limitations
6095

6196
- no rendering of shadow DOM

0 commit comments

Comments
 (0)