Skip to content

Commit 24b15f9

Browse files
committed
[update] complete the pdf() method's page
1 parent cea9676 commit 24b15f9

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

docs/api/export/pdf_method.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: You can learn about the pdf method in the documentation of the DHTM
1111
@short: Exports a diagram to a PDF file
1212

1313
:::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.
1515
:::
1616

1717
### Usage
@@ -23,19 +23,31 @@ pdf(config?: object): void;
2323
### Parameters
2424

2525
- `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
3951

4052
### Example
4153

@@ -55,6 +67,28 @@ diagram.export.pdf({
5567
});
5668
~~~
5769

70+
### Details
71+
72+
:::info
73+
It is necessary to set sufficient margin for correct display of `headerTemplate`/`footerTemplate`.
74+
:::
75+
76+
## List of formats
77+
78+
| Format | Size |
79+
| --------- | ------------------ |
80+
| "Letter" | (8.5in x 11in) |
81+
| "Legal" | (8.5in x 14in) |
82+
| "Tabloid" | (11in x 17in) |
83+
| "Ledger" | (17in x 11in) |
84+
| "A0" | (33.1in x 46.8in) |
85+
| "A1" | (23.4in x 33.1in) |
86+
| "A2" | (16.54in x 23.4in) |
87+
| "A3" | (11.7in x 16.54in) |
88+
| "A4" | (8.27in x 11.7in) |
89+
| "A5" | (5.83in x 8.27in) |
90+
| "A6" | (4.13in x 5.83in) |
91+
5892
**Related articles**: [Exporting Diagram](../../../guides/data_export/)
5993

6094
**Related samples**: [Diagram. Export. Export diagram](https://snippet.dhtmlx.com/ybpmz0zk)

0 commit comments

Comments
 (0)