Reputation: 1160
iam using dompdf to generate pdf file from html , the problem is the generated filesize is big ,i.e. 1MB for 1 page of pdf ! is there any way to reduce it ?
Upvotes: 6
Views: 13329
Reputation: 8489
If you're using barryvdh/laravel-dompdf, using the following config can reduce the file size drastically:
config/dompdf.php
"enable_font_subsetting" => true,
I reduced the pdf size from 4.2 MB to 34 KB in this way.
Upvotes: 11
Reputation:
fonts and images are the primary size issue, use the internal fonts, so you don't have to embed them, and make sure any images are optimised.
PDFs include support by default for Helvetica, Times-Roman, Courier and Zapf-Dingbats. You do not need to install any font files if you wish to use these fonts. This has the advantage of reducing the size of the resulting PDF, because additional fonts must be embedded in the PDF. http://code.google.com/p/dompdf/wiki/Installation
Upvotes: 12