You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/export/pdf_method.md
+48-14Lines changed: 48 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ description: You can learn about the pdf method in the documentation of the DHTM
11
11
@short: Exports a diagram to a PDF file
12
12
13
13
:::note
14
-
To avoid problems during export, all images for Diagram shapes must be set either in base64 format or via an absolute URL
14
+
To avoid problems during export, all images for Diagram shapes must be set either in the base64 format or via an absolute URL.
15
15
:::
16
16
17
17
### Usage
@@ -23,19 +23,31 @@ pdf(config?: object): void;
23
23
### Parameters
24
24
25
25
-`config` - (optional) an object with export settings. You can specify the following settings for export to PDF:
26
-
-`url: string` - the url of the service that executes export and returns an exported file. This setting is optional, you should use it only if you need to specify the path to your local export service. The default value is `https://export.dhtmlx.com/diagram/pdf/5.0.0`
27
-
-`name: string` - the name of the exported file
28
-
-`pdf: object` - the options object. It can have the following properties:
29
-
- `scale: number` - the scale of the chart rendering (between **0.1** and **2**)
30
-
- `landscape: boolean` - paper orientation, **false** by default
31
-
- `format: string` - paper format. If set, takes priority over width or height options. **'Letter'** by default. Read more about formatting [here](https://github.com/puppeteer/puppeteer/blob/v16.0.0/docs/api/puppeteer.paperformat.md)
32
-
- `width: string | number` - paper width. As a value of the property, you can specify a number or a string with a unit
33
-
- `height: string | number` - paper height. As a value of the property, you can specify a number or a string with a unit
34
-
- `margin: object` - paper margins, none by default
35
-
- `top: string | number` - top margin, accepts values labeled with units
36
-
- `right: string | number` - right margin, accepts values labeled with units
37
-
- `bottom: string | number` - bottom margin, accepts values labeled with units
38
-
- `left: string | number` - left margin, accepts values labeled with units
26
+
-`url?: string` - (optional) the url of the service that executes export and returns an exported file. This setting is optional, you should use it only if you need to specify the path to your local export service. The default value is `https://export.dhtmlx.com/diagram/pdf/5.0.0`
27
+
-`name?: string` - (optional) the name of the exported file
28
+
-`pdf?: object` - (optional) the object of pdf options. Here you can specify the following properties:
29
+
- `scale?: number` - (optional) the scale of the grid rendering (between *0.1* and *2*)
30
+
- `landscape?: boolean` - (optional) defines a landscape orientation, ***false*** by default. It works only if the `format` option is specified
31
+
- `width?: string | number` - (optional) the width of the output page. As a value of the property, you can specify a number or a string with a unit
32
+
- `height?: string | number` - (optional) the height of the output page. As a value of the property, you can specify a number or a string with a unit
33
+
- `margin?: object` - (optional) the object with paper margins, ***none*** by default
34
+
- `left?: string | number` - (optional) defines a left margin, accepts values labeled with units (px,in,cm,mm)
35
+
- `right?: string | number` - (optional) defines a right margin, accepts values labeled with units (px,in,cm,mm)
36
+
- `top?: string | number` - (optional) defines a top margin, accepts values labeled with units (px,in,cm,mm)
37
+
- `bottom?: string | number` - (optional) defines a bottom margin, accepts values labeled with units (px,in,cm,mm)
38
+
- `format?: string` - (optional) defines the paper format. If set, it takes priority over the **width** or **height** options. Not specified by default. Check the list of all available [formats and their sizes](#list-of-formats).
39
+
- `pageRanges?: string` - (optional) paper ranges to print, e.g. 1-5, 8, 11-13. It works only if the `format` option is specified
40
+
- `displayHeaderFooter?: boolean` - (optional) defines whether to display the header and footer, *false* by default
41
+
- `footerTemplate?: string` - (optional) an HTML template for the print footer. It should be a valid HTML markup with the following classes used to inject printing values into them:
42
+
- `date` - (optional) the formatted print date
43
+
- `title` - (optional) the document name
44
+
- `pageNumber` - (optional) the current page number. It is used by default
45
+
- `totalPages` - (optional) the total number of pages in the document. It is used by default
46
+
- `headerTemplate?: string` - (optional) an HTML template for the print header. It should be a valid HTML markup with the following classes used to inject printing values into them:
47
+
- `date` - (optional) the formatted print date
48
+
- `title` - (optional) the document name
49
+
- `pageNumber` - (optional) the current page number
50
+
- `totalPages` - (optional) the total number of pages in the document
39
51
40
52
### Example
41
53
@@ -55,6 +67,28 @@ diagram.export.pdf({
55
67
});
56
68
~~~
57
69
70
+
### Details
71
+
72
+
:::info
73
+
It is necessary to set sufficient margin for correct display of `headerTemplate`/`footerTemplate`.
0 commit comments