Skip to content

Commit a8f8f8b

Browse files
author
Maria Rudenko
committed
Merge pull request '[update] guides and api for export to pdf' (#103) from next into master
Reviewed-on: https://git.webix.io/Servers/gantt-docs/pulls/103
2 parents 87d2818 + 5f5b432 commit a8f8f8b

File tree

2 files changed

+97
-16
lines changed

2 files changed

+97
-16
lines changed

data/api/gantt_exporttopdf.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ The api/gantt_exporttopdf.md method takes as a parameter an object with a number
9292
</tr>
9393
<tr>
9494
<td class="webixdoc_links0"><b>raw</b></td>
95-
<td>(<i>boolean</i>) defines that all Gantt markup will be exported as it is, with all custom elements. <em>false</em> by default. <a href="desktop/export.md#exportingcustommarkupandstyles">Read the details</a> </td>
95+
<td>(<i>boolean</i>) defines that all Gantt markup will be exported as it is, with all custom elements. <em>false</em> by default.
96+
<a href="desktop/export.md#exportingcustommarkupandstyles">Read the details</a> </td>
9697
</tr>
9798
<tr>
9899
<td class="webixdoc_links0"><b>callback</b></td>
@@ -102,14 +103,20 @@ The api/gantt_exporttopdf.md method takes as a parameter an object with a number
102103
<td class="webixdoc_links0"><b>additional_settings</b></td>
103104
<td>(<i>object</i>) an object with additional settings. The object can contain the following attributes:
104105
<ul>
105-
<li><b>format</b> - (<i>string</i>) the format of the output file: <i>'A3', 'A4', 'A5', 'Legal', 'Letter', 'Tabloid'</i></li>
106-
<li><b>landscape</b> - (<i>boolean</i>) the portrait or landscape orientation of the output file. The attribute works only when the "format" attribute is specified.</li>
107-
<li><b>width</b> - (<i>string|number|"content"</i>) the width of the output page. The attribute is used when exporting multiple pages. </li>
108-
<li><b>height</b> - (<i>string|number|"content"</i>) the height of the output page. The attribute is used when exporting multiple pages.</li>
109-
<li><b>merge_pages</b> - (<i>boolean</i>) enables the multipage export in one file; if set to <i>false</i> you will have to make export several times to get
110-
all the Gantt data</li>
106+
<li><b>format</b> - (<i>string</i>) the format of the output file:
107+
<i>"A0", "A1", "A2", "A3", "A4", "A5", "A6", "Legal", "Ledger", "Letter", "Tabloid"</i></li>
108+
<li><b>landscape</b> - (<i>boolean</i>) the portrait or landscape orientation of the output file. The attribute works only when the "format" attribute is specified</li>
109+
<li><b>width</b> - (<i>string|number|"content"</i>) the width of the output page. The attribute is used when exporting multiple pages</li>
110+
<li><b>height</b> - (<i>string|number|"content"</i>) the height of the output page. The attribute is used when exporting multiple pages</li>
111+
<li><b>merge_pages</b> - (<i>boolean</i>) enables the <a href="#multipageexport">multipage export</a> in one file; if set to <i>false</i> you will have to make export several times to get all the Gantt data</li>
111112
<li><b>fixed_headers</b> - (<i>boolean</i>) enables displaying of the grid and timeline headers on each page; <i>false</i> by default. Works only with
112113
the enabled <b>merge_pages</b> setting</li>
114+
<li><b>margins</b> - (<i>object</i>) the object with the top, bottom, left and right margins for the output PDF file.
115+
<a href="desktop/export.md#marginsoftheoutputpdffile">Read the details</a></li>
116+
<li><b>header</b> - (<i>string</i>) specifies the header that will be added to each page of the output PDF file.
117+
<a href="desktop/export.md#headerfooterforeachpage">Read the details</a></li>
118+
<li><b>footer</b> - (<i>string</i>) specifies the footer that will be added to each page of the output PDF file.
119+
<a href="desktop/export.md#headerfooterforeachpage">Read the details</a></li>
113120
</ul>
114121
</td>
115122
</tr>

data/desktop/export.md

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ The api/gantt_exporttopdf.md and api/gantt_exporttopng.md methods take as a para
162162
</tr>
163163
<tr>
164164
<td class="webixdoc_links0"><b>raw</b></td>
165-
<td>(<i>boolean</i>) defines that all Gantt markup will be exported as it is, with all custom elements. <em>false</em> by default. <a href="desktop/export.md#exportingcustommarkupandstyles">Read the details below</a> </td>
165+
<td>(<i>boolean</i>) defines that all Gantt markup will be exported as it is, with all custom elements. <em>false</em> by default.
166+
<a href="#exportingcustommarkupandstyles">Read the details below</a> </td>
166167
</tr>
167168
<tr>
168169
<td class="webixdoc_links0"><b>callback</b></td>
@@ -172,14 +173,22 @@ The api/gantt_exporttopdf.md and api/gantt_exporttopng.md methods take as a para
172173
<td class="webixdoc_links0"><b>additional_settings</b></td>
173174
<td>(<i>object</i>) an object with additional settings for the <b>exportToPDF()</b> method. The object can contain the following attributes:
174175
<ul>
175-
<li><b>format</b> - (<i>string</i>) the format of the output file: <i>'A3', 'A4', 'A5', 'Legal', 'Letter', 'Tabloid'</i></li>
176-
<li><b>landscape</b> - (<i>boolean</i>) the portrait or landscape orientation of the output file. The attribute works only when the "format" attribute is specified.</li>
176+
<li><b>format</b> - (<i>string</i>) the format of the output file:
177+
<i>"A0", "A1", "A2", "A3", "A4", "A5", "A6", "Legal", "Ledger", "Letter", "Tabloid"</i></li>
178+
<li><b>landscape</b> - (<i>boolean</i>) the portrait or landscape orientation of the output file.
179+
The attribute works only when the "format" attribute is specified.</li>
177180
<li><b>width</b> - (<i>string | number | "content"</i>) the width of the output page. The attribute is used when exporting multiple pages. </li>
178181
<li><b>height</b> - (<i>string | number | "content"</i>) the height of the output page. The attribute is used when exporting multiple pages.</li>
179-
<li><b>merge_pages</b> - (<i>boolean</i>) enables the multipage export in one file;
182+
<li><b>merge_pages</b> - (<i>boolean</i>) enables the <a href="api/gantt_exporttopdf.md#multipageexport">multipage export</a> in one file;
180183
if set to <i>false</i> you will have to make export several times to get all the Gantt data</li>
181184
<li><b>fixed_headers</b> - (<i>boolean</i>) enables displaying of the grid and timeline headers on each page; <i>false</i> by default. Works only with
182185
the enabled <b>merge_pages</b> setting</li>
186+
<li><b>margins</b> - (<i>object</i>) the object with the top, bottom, left and right margins for the output PDF file.
187+
<a href="#marginsoftheoutputpdffile">Read the details below</a></li>
188+
<li><b>header</b> - (<i>string</i>) specifies the header that will be added to each page of the output PDF file.
189+
<a href="#headerfooterforeachpage">Read the details below</a></li>
190+
<li><b>footer</b> - (<i>string</i>) specifies the footer that will be added to each page of the output PDF file.
191+
<a href="#headerfooterforeachpage">Read the details below</a></li>
183192
</ul>
184193
</td>
185194
</tr>
@@ -236,7 +245,7 @@ gantt.exportToPNG({
236245
});
237246
~~~
238247

239-
##Name of the output file
248+
## Name of the output file
240249

241250
To set a custom name for the output file, use the **name** property in the parameter of the [exportToPDF/exportToPNG](desktop/export.md#parametersoftheexportmethods) methods:
242251

@@ -246,7 +255,7 @@ gantt.exportToPDF({
246255
});
247256
~~~
248257

249-
##Language of the output file
258+
## Language of the output file
250259

251260
By default, the Gantt chart will be exported in the same language as it is shown on the page.
252261

@@ -270,7 +279,7 @@ To set the tasks that should be presented in the output PDF or PNG file, use one
270279

271280
<a id="daterange"></a>
272281

273-
###Specifying the date range of the output tasks
282+
### Specifying the date range of the output tasks
274283

275284
To set the range of tasks that will be presented in the output document, use the **start**, **end** properties in the parameter of the [exportToPDF/exportToPNG](desktop/export.md#parametersoftheexportmethods) methods:
276285

@@ -288,7 +297,7 @@ Note, the date format is defined by the api/gantt_date_format_config.md config.
288297

289298
<a id="customdata"></a>
290299

291-
###Setting a custom data source to export
300+
### Setting a custom data source to export
292301

293302
To export the Gantt chart with a custom data set (i.e. not with the data presented in the initial Gantt chart), use the **data** property in the parameter of the
294303
[exportToPDF/exportToPNG](desktop/export.md#parametersoftheexportmethods) methods:
@@ -315,7 +324,7 @@ gantt.exportToPDF({
315324
Note, you cannot specify some URL as the value of the **data** parameter, just a data object.
316325
}}
317326

318-
##Skin of the output Gantt chart
327+
## Skin of the output Gantt chart
319328

320329
By default, the Gantt chart will be exported with the same skin as it is shown on the page.
321330

@@ -347,6 +356,71 @@ gantt.exportToPDF({
347356
});
348357
~~~
349358

359+
<h3 id="headerfooterforeachpage">Header/footer for each page of the output PDF file</h3>
360+
361+
To add a header/footer for each page of the output PDF file, use the **header**/**footer** properties in the **additional_settings** object of the `exportToPDF` method.
362+
363+
You can specify the number of the current page by using the element with `class="pageNumber"` and the total number of pages by using the
364+
element with `class="totalPages"` in the **header**/**footer** properties:
365+
366+
~~~js
367+
gantt.exportToPDF({
368+
additional_settings: {
369+
format: "A4",
370+
// correct margins are obligatory to render headers/footers
371+
margins: {
372+
top: 10,
373+
bottom: 10,
374+
left: 0.1,
375+
right: 1
376+
},
377+
header:"Each page header",
378+
footer:'Page: <span class="pageNumber"></span>/<span class="totalPages"></span>',
379+
},
380+
});
381+
~~~
382+
383+
Note that these settings work only when [**margins**](#marginsoftheoutputpdffile) are specified and there is enough space to display the header/footer correctly.
384+
Otherwise, headers/footers will be rendered outside the gantt. It is recommended to set *10* as a minimal margin for a plain line of text.
385+
386+
## Margins of the output PDF file
387+
388+
To add margins to the output PDF file, use the **margins** property in the **additional_settings** object of
389+
the [exportToPDF](desktop/export.md#parametersoftheexportmethods) method. The **margins** property works both for one-page and
390+
<a href="api/gantt_exporttopdf.md#multipageexport">multipage export</a>.
391+
392+
The values of margin settings are specified as numbers:
393+
394+
~~~js
395+
gantt.exportToPDF({
396+
additional_settings: {
397+
margins: {
398+
top: 5,
399+
bottom: 10,
400+
left: 2,
401+
right: 2
402+
},
403+
},
404+
});
405+
~~~
406+
407+
If some of the margin settings isn't specified, it will be ignored.
408+
409+
The values are set in millimeters by default, but you can specify the values of margins in inches by setting the <b>unit: "inch"</b> property:
410+
411+
~~~js
412+
gantt.exportToPDF({
413+
additional_settings: {
414+
margins: {
415+
top: 5,
416+
bottom: 10,
417+
left: 2,
418+
right: 2,
419+
unit: "inch" /*!*/
420+
},
421+
},
422+
});
423+
~~~
350424

351425
## Custom style for the output file
352426

0 commit comments

Comments
 (0)