toPDF of common helpers, Methods Webix Docs
| promise | a "promise" object. The promise is resolved with the contents of a PDF file that is ready for downloading. |
Example
webix.toPDF($$("table"),{
filename: "datatable",
// other config options
});
Related samples
Details
If the first parameter is the array of IDs, several views are exported.
webix.toPDF(["datatable","chart"]);
Configuration options can contain several useful settings. For example, canvas-based components like Chart can be exported as images, if you pass display:"image" parameter:
webix.toPDF("chart", { display:"image" });
Changing Font for Exported File
By default, Webix provides the pt-sans.regular.ttf font file for export. If it doesn't suit you, e.g. you need specific characters that are not included in the font, you can add another file to the "extras" folder and define the fontName option:
webix.toPDF($$("mylist"), { fontName:"custom" });
Or you can specify the URL of the font you need in the fontURL parameter:
webix.toPDF("$dt",{
fontName:"name",
fontURL:"url",
})
Related sample: Export to PDF: Changing Font
Note that only .ttf font files are supported.
Customizing Export a Datatable to PDF
The method returns all data specified in the columns parameter of a datatable view. The data are exported into a PDF document with the "data" name.
However, you may need to get some particular data or customize file properties.
Export API allows
- export several components into one PDF document
- providing a custom filename
- disabling file download in a browser
- defining the PDF page orientation
- stripping HTML tags from the cells
- setting custom columns for export
- defining custom header, width or template for data in the specified column
- rendering a template set in the widget dataset
- including extra fields into export
- defining the columns' width automatically
- displaying some text or image in the header of the export file
- ignoring particular columns
- outputting certain data from a data set
- modifying data of exported items
- omitting the header or footer of Datatable during export
See also