[cairo] [PATCH] [pdf] Use deflate stream when writing images.

Adrian Johnson ajohnson at redneon.com
Mon Feb 11 13:01:09 PST 2008

Kristian Høgsberg wrote:
> I wanted to eliminate compress_dup() completely, but for font subsets we
> need the compressed_size up front for the /Length attribute of the dict.
> I was a bit puzzled by the fact that we don't use that for images, since the
> PDF specification says that it's required for all streams... maybe we could
> just leave it out for fonts streams as well, or alternatively, make the length
> an indirect object as we do for content streams.

The /Length is there. _cairo_pdf_surface_open_stream() adds /Length as
an indirect object.  When the stream is closed it calculates the length
and inserts the length indirect object.

In fact the patch can be simplified. The third argument of
_open_stream() is a boolean specifying if the stream is to be
compressed. You should be able to set this flag to true, remove the
/Filter that _emit_image() is adding to the dictionary and write the
uncompressed data.

This can be easily done for fonts as well.

More information about the cairo mailing list