eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.13k stars 1.39k forks source link

Why is the file size so big? #103

Open raphaelrupprecht opened 6 years ago

raphaelrupprecht commented 6 years ago

Hi there,

I compared the file sizes of the same HTML DOM (435 Elements) in html2canvas and html2pdf: html2canvas creates an image with 50 KB html2pdf creates a pdf with 12 MB

Can anyone explain that to me? I mean it's just adding the same small 50 KB image to a PDF.

Thanks in advance!

macfire commented 6 years ago

From what I can tell, the HTML content is converted to an image (via canvas) before eventually being saved to PDF. Many times, a PDF with text will embed the font, which is generally vector and smaller in file size.

See: https://github.com/eKoopmans/html2pdf#image-type-and-quality