A SnapDOM plugin that renders a webpage as a pdf with selectable text and links via html2pdf.js
npm i snapdom-html2pdf-pluginimport { 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 })| 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). |
MIT