pdf()
Description
Exports a diagram to a PDF file
note
To avoid problems during export, all images for Diagram shapes must be set either in base64 format or via an absolute URL
Usage
pdf(config?: object): void;
Parameters
config
- (optional) an object with export settings. You can specify the following settings for export to PDF: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 ishttps://export.dhtmlx.com/diagram/2.0.0/pdf
name: string
- the name of the exported fileheader: string
- specifies the header that will be added to the resulted PDF file. You can use any HTML herefooter: string
- specifies the footer that will be added to the resulted PDF file. You can use any HTML herepdf: object
- the options object. It can have the following properties:scale: number
- the scale of the webpage rendering, 1 by defaultdisplayHeaderFooter: boolean
- displays header and footer, false by defaultheaderTemplate: string
- an HTML template for the print header. It should be valid HTML markup with following classes used to inject printing values into them:date
- formatted print datetitle
- document titleurl
- document locationpageNumber
- current page numbertotalPages
- total pages in the document
footerTemplate: string
- an HTML template for the print footer. Should use the same format as the headerTemplateprintBackground: boolean
- print background graphics, false by defaultlandscape: boolean
- paper orientation, false by defaultpageRanges: string
- paper ranges to print, e.g., '1-5, 8, 11-13'. By default it is set to an empty string, which means print all pagesformat: string
- paper format. If set, takes priority over width or height options. 'Letter' by defaultwidth: string
- paper width, accepts values labeled with unitsheight: string
- paper height, accepts values labeled with unitsmargin: object
- paper margins, none by defaulttop: string
- top margin, accepts values labeled with unitsright: string
- right margin, accepts values labeled with unitsbottom: string
- bottom margin, accepts values labeled with unitsleft: string
- left margin, accepts values labeled with units
Example
const diagram = new dhx.Diagram("diagram_container", {
// config options
});
diagram.data.parse(data);
// default export
diagram.export.pdf();
// export with config settings
diagram.export.pdf({
url: "https://export.dhtmlx.com/diagram/2.0.0/pdf",
name:"result.pdf"
});
Related articles: Exporting Diagram
Related samples: Diagram. Export. Export diagram