snapdom-html2pdf-plugin
v1.0.0
Published
A starter template for building SnapDOM plugins
Maintainers
Readme
snapdom html2pdf plugin
A SnapDOM plugin that renders a webpage as a pdf with selectable text and links via html2pdf.js
Install
# npm coming soon....
clone https://github.com/jswhisperer/snapdom-plugin-fullpdfimport { snapdom } from '@zumer/snapdom'
import { html2pdfSnap } from 'snapdom-html2pdf-plugin'
snapdom.plugins([html2pdfSnap, { opts }])
const capture = document.getElementById("capture")
await result.toHtml2pdfSnap({ element: capture, html2pdfSnap })Options
| Name | Type | Default | Description |
| ----------- | --------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| margin | number or array | 0 | PDF margin (in jsPDF units). Can be a single number, [vMargin, hMargin], or [top, left, bottom, right]. |
| filename | string | 'file.pdf' | The default filename of the exported PDF. |
| pagebreak | object | {mode: ['css', 'legacy']} | Controls the pagebreak behaviour on the page. See Page-breaks below. |
| image | object | {type: 'jpeg', quality: 0.95} | The image type and quality used to generate the PDF. See Image type and quality below. |
| enableLinks | boolean | true | If enabled, PDF hyperlinks are automatically added ontop of all anchor tags. |
| html2canvas | object | { } | Configuration options sent directly to html2canvas (see here for usage). |
| jsPDF | object | { } | Configuration options sent directly to jsPDF (see here for usage). |
License
MIT
