toPDF

exports data of a data component to a PDF file

object toPDF(string|object|array id, [object options] );

Parameters

idstring|object|arraythe exported view or its ID or an array of IDs
optionsobjectoptional, configuration options

Returns

objecta "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" });

Customizing Export a Datatable to PDF

The method returns all data specified in the columns parameter of a datatable view. The data is 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

  1. export several components into one PDF document
  2. providing a custom filename
  3. disabling file download in a browser
  4. defining the PDF page orientation
  5. stripping HTML tags from the cells
  6. setting custom columns for export
  7. defining custom header, width or template for data in the specified column
  8. rendering a template set in the widget's dataset
  9. including extra fields into export
  10. defining the columns' width automatically
  11. displaying some text or image in the header of the export file
  12. ignoring particular columns
  13. outputting certain data from a data set
  14. modifying data of exported items
  15. omitting the header or footer of Datatable during export
See also
Back to top