HTML to PDF, right in your browser.
daeepdf turns HTML and CSS into a PDF in the page that asks for it. Pick a sample or paste HTML of your own, and daeepdf makes the PDF and times it. html2pdf.js, a widely used way to make a PDF in the browser, makes the same one beside it, so you can compare the files themselves: their size, their text and their links. Nothing you paste leaves your browser.
Pick a sample or edit its HTML, then press Run. Nothing leaves your browser.
| Measure | daeepdf | html2pdf.js 0.14.0 | Difference |
|---|---|---|---|
| File size | |||
| Time | |||
| Pages | |||
| Text | |||
| Links | |||
| Tagged for screen readers |
The calls behind it
What each run calls, the way each library's own docs show it.
daeepdf
import pdf from 'daeepdf'
const file = await pdf.render(html, { margin: 40, useAppStyles: false })
const bytes = file.byteshtml2pdf.js
import html2pdf from 'html2pdf.js'
// The template on a page of its own, so its CSS applies
const page = document.createElement('div')
page.innerHTML = html
document.body.append(page)
const bytes = await html2pdf()
.set({
margin: 40,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'pt', format: 'a4', orientation: 'portrait' },
})
.from(page)
.outputPdf('arraybuffer')How it's measured
- Both libraries get the same HTML, on A4 pages with 40 pt margins. Neither sees this page's own CSS: daeepdf runs with
useAppStyles: false, and html2pdf.js in a page of its own that holds only the template. - html2pdf.js runs with the settings its README shows: JPEG images at 0.98 quality, drawn by html2canvas at twice the size.
- Each library makes the PDF once to warm up, which loads its code, daeepdf's 3 MB engine and the template's fonts. It then makes it 3 more times, the one going first swapping each time, and the time is the median of those 3.
- Both run on this page's main thread, so the page can pause while they work. Stop ends daeepdf's PDF at its next step; html2pdf.js can't be stopped partway, so it finishes the one it's making.
- Everything but the time is read from the PDFs themselves: the pages, whether the page content draws text or only images, the link annotations, and whether there's a structure tree for screen readers.
- This page's security policy lets nothing load from anywhere but this site, so a template's images and fonts have to be here too, or written into it as
data:URLs. - The numbers are your device's own, and other busy tabs make them noisier. A KB here is 1,024 bytes.
About html2pdf.js
html2pdf.js 0.14.0 is by Erik Koopmans, under the MIT license. It draws the page with html2canvas and puts each page into the PDF as a JPEG image, with jsPDF. Its source is at github.com/eKoopmans/html2pdf.js.