SnapDOM PDF vs html2canvas + jsPDF: searchable invoices from HTML
Compare image PDFs, searchable DOM captures and programmatic jsPDF. Try one editable invoice across three real export routes.
What the PDF contains
An invoice PDF needs three things checked: the layout, whether the text can be selected, and whether payment links work. The three export routes below handle them differently.
PDF export first shipped in the 4.0.0 plugin toolbox. It now installs separately as @zumer/snapdom-pdf. Its visible page is a captured image; an invisible PDF text layer adds selection and search.
SnapDOM PDF vs html2canvas + jsPDF vs jsPDF
SnapDOM + PDF plugin: capture the invoice you already have
The PDF looks like the HTML invoice. The text layer lets the recipient search the invoice number and copy text, and links can stay clickable.
Use this when your app already displays the document you want to export. The visible page is still an image; zooming in does not turn it into vector artwork.
html2canvas + jsPDF: put a screenshot inside a PDF
html2canvas turns the HTML into an image and jsPDF puts that image on a PDF page. The invoice text is part of the image: the recipient cannot select or search it.
Use this when an image inside a PDF is enough. Selectable text or clickable links take more code.
jsPDF directly: build a separate PDF layout
You write the text and draw the document with jsPDF’s APIs. The text is selectable and you can add links; you also choose positions, fonts and page breaks yourself.
Use this when the PDF should have its own layout. It does not copy the appearance of your HTML invoice.
jsPDF writes text, graphics and links directly; its separate html() API depends on html2canvas. The table and demo compare the common addImage() recipe with programmatic jsPDF. See the jsPDF README and HTML API reference.
html2canvas implements a documented subset of CSS rather than asking the browser for a native screenshot, and its feature list currently marks box-shadow and filter unsupported. Check the exported invoice against the source if it uses those styles.
Try the same invoice three ways
Change the client name below, generate each PDF, and search for that name in the files. Compare selection, link behavior and the visible header. The programmatic jsPDF version uses the same invoice data with its own layout.
For a larger acceptance test, open the PDF playground, select A4 ledger, and check row breaks and repeated table headers. The multilingual and form examples cover other scripts and editable fields.
Install and export
npm install @zumer/snapdom@3 @zumer/snapdom-pdfimport { snapdom } from '@zumer/snapdom';
import { pdf } from '@zumer/snapdom-pdf';
await document.fonts.ready;
const invoice = document.querySelector('#invoice');
const result = await snapdom(invoice, { plugins: [pdf()] });
const blob = await result.toPdf({ page: 'a4', margin: 36 });
// Upload the Blob, or opt into a download:
await result.toPdf({ page: 'a4', download: 'invoice.pdf' });Wait for the application's data and images as well as fonts. Capture options go on snapdom() or the plugin factory, paper options on toPdf(). Output options are in the PDF reference.
Document checks before shipping
Search for a unique invoice identifier, copy a full line item, click a known link, inspect page two, and open the file in the viewer your recipients use. The exporter supports pagination and repeated table headers, but a row taller than a page still has to split. Tagged output by itself does not establish PDF/UA conformance.
Remove sensitive source content before capture. A painted rectangle hides pixels while leaving searchable text underneath. The downloadable document and the browser preview belong under the same redaction policy.
Continue with the capture pipeline
Start with choosing the capture element, then capture options and cache and recapture behavior. For editable SVG and Figma output, see the Vector and Figma workflow.
Sources checked October 5, 2026: published plugins 4.0.0, PDF implementation and reference, html2canvas architecture, and the jsPDF references above.