Reputation: 120
We have an apllication generates dynamic PDF files with embeded NMSYS fonts.
But it's size is very large in comparision to the original file having larger data then dynamically generated having same fonts.
Is it possible to reduce size of such PDF with php any script, API or extention ? and why the source PDF (not generated by script) of larger contents and same fonts have less size ?
EDIT
Example -
file -1 is generated by our script it's bacically showing a piece of information from file 2. There are only 5 pages in file -1 and it's of 1.2 MB and file 2 having 158 pages of similar information but of approx 4MB.
why this size difference is there?
Upvotes: 2
Views: 5444
Reputation: 7046
I looked at both files and the difference is indeed mostly font related. I saved both files optimised with Adobe Acrobat XI - this (can do) does a whole lot of optimisations but the most important difference (for file 1) comes from font subsetting:
File 1: 1.2 MB before / 253 KB after File 2: 4.7 MB before / 3.7 MB after
Your file 2 was created using FrameMaker which normally produces pretty clean PDF (even if a very old version of Adobe Acrobat Distiller was used in this case), your file 1 was generated by DomPDF, apparently without subsetting embedded fonts.
If you look at the space audit report out of Acrobat for your first file:
You can see that the fonts take up close to 96% of the space in the file. So subsetting the font used in this file is basically your only option to make it smaller.
Different libraries or applications have different options to enable subsetting. Specifically for DOMPDF use the option DOMPDF_ENABLE_FONTSUBSETTING to enable font subsetting in the PDF files it creates:
def("DOMPDF_ENABLE_FONTSUBSETTING", true);
This then embeds only those characters actually used in the PDF file, often (depending on the amount of text and the actual font) creating much smaller files.
(DOMPDF solution added from comments to make answer more complete)
Upvotes: 5
Reputation: 5834
The file 1 uses the TrueType DejaVuSans family of fonts and they are not subset. They take about 950kb of the PDF file. The rest are images, PDF structures, etc.
The file 2 uses TrueType Helvetica fonts and they are subset. They take much less space. Because all the text on all pages uses almost the same characters the final font size is quite small.
Upvotes: 2