Skip to content

jswhisperer/snapdom-plugin-html2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snapdom html2pdf plugin

A SnapDOM plugin that renders a webpage as a pdf with selectable text and links via html2pdf.js

Install

npm i snapdom-html2pdf-plugin
import { 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

html2pdf docs

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

About

A SnapDOM plugin that renders a webpage as a pdf with selectable text and links via html2pdf.js

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors