[cairo] cairo-created PDFs are too large

Adrian Johnson ajohnson at redneon.com
Wed Dec 3 00:58:58 PST 2008


Isenko Evgeny wrote:
> Hello,
> 
> PDF files, created with Cairo, seem to be much bigger than I expected.
> 
> PDFs contain only simple graphics and some japanese text. It seems that
> using even small number of japanese letters makes the size of the output
> PDF much bigger. A similar PDF created with iTextSharp library was only
> 20 kB against 100 kB of the PDF created with Cairo.

Without seeing the cairo and iTextSharp generated PDFs it is difficult 
to know exactly what is causing the additional size. You mentioned that 
using a small number of glyphs makes the PDF size a lot larger. I expect 
this is due to the subsetted and embedded fonts. While the fonts are 
subsetted to contain only the glyphs used, there is a fixed overhead of 
various tables included with each font. For very large fonts such as CJK 
fonts these fixed size tables can be large. This is most noticeable with 
OpenType/CFF fonts as I have not yet implemented subsetting of the 
global subroutines in the font. iTextSharp may be either not embedding 
the fonts (which is not recommended by the PDF specification and not 
something we will do). Or instead of subsetting the fonts it may be 
creating a new font containing only the outlines without any of the 
hinting included.

Reducing the size of PDF files is an on going project. For example 
version 1.6 greatly reduced the use of fallback images. Version 1.8 had 
a large improvement when a lot of text is used. Version 1.10 when 
released will allow JPEG and other lossy image formats to be embedded 
instead of expanding them to Deflate compressed bitmaps. Also planned is 
a feature that will avoid embedding the same image or pattern every time 
it is used.

> Would someone give me advice how to decrease the size of the output PDFs?

There isn't anything you can do to reduce the size other than upgrade to 
each new release when available. There are some things you can do that 
would increase the size unnecessarily like creating a new font face each 
time you draw some text as cairo embeds a separate font for each font face.

> 
> PS: For text drawing I use pango and pangocairo.
> 
> Thanks for any help.
> 
> Evgeny
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo



More information about the cairo mailing list