


The Worker object returned by html2pdf() has a built-in progress-tracking mechanism. To enable png image compression, try using the canvas-png-compression shim, which should be an in-place solution to enable png compression via the quality option. These options are limited to the available settings for HTMLCanvasElement.toDataURL(), which ignores quality settings for ‘png’ images. This setting is only used for jpeg/webp (not png). HTMLCanvasElement only supports ‘png’, ‘jpeg’, and ‘webp’ (on Chrome). This must be an object with the following fields: Name You may customize the image type and quality exported from the canvas by setting the image option. getElementById ( ' element-to-print ' ) var opt = ) Image type and quality Html2pdf.js can be configured using an optional opt parameter:

Throws an error in the Worker’s Promise chain.Ī few aliases are also provided for convenience: Method catchExternal exits the Worker chain - you will not be able to continue chaining Worker methods after. Using this ‘exits’ the Worker chain - you will not be able to continue chaining Worker methods after. thenCore returns a Worker, which is a subclass of Promise. Standard Promise method, with this re-bound to the Worker (no progress-tracking). then returns a Worker, which is a subclass of Promise. Standard Promise method, with this re-bound to the Worker, and with added progress-tracking (see Progress below). then to access), or by calling cbk if provided. Returns the property specified in key, either as a Promise (use. Saves the PDF object with the optional filename (creates user download prompt). Supported types: 'img', 'datauristring'/ 'dataurlstring', and 'datauri'/ 'dataurl'. Returns the specified data type for the image as a Promise (use. Sends type and options to the jsPDF object’s output method, and returns the result as a Promise (use. Routes to the appropriate outputPdf or outputImg method based on specified src ( 'pdf' (default) or 'img'). Each target also has its own toX method that can be called directly: toContainer(), toCanvas(), toImg(), and toPdf(). Optional type specifies other sources: 'string', 'element', 'canvas', or 'img'.Ĭonverts the source to the specified target ( 'container', 'canvas', 'img', or 'pdf'). Sets the source (HTML string or element) for the PDF.
