[cairo] Cairo PDF

Adrian Johnson ajohnson at redneon.com
Thu Jun 16 05:27:36 PDT 2011

On 16/06/11 21:10, William Temperley wrote:
> Dear all,
> I've been embedding PNG images into PDFs using Cairo for a while via
> the Java-Gnome bindings (and getting some great results, thanks!).
> After upgrading from Cairo 1.8.10 to 1.10.2, embedded PNGs appear
> blurry in both Acrobat reader and Evince. (I'm now using Java-Gnome
> 4.0.19 - before I was on 4.0.14).  The Java-Gnome developers say
> nothing has changed WRT to image embedding from their side, so it is
> likely this is down to a change in Cairo.
> This is best illustrated with maps produced the different libraries:
> With Cairo 1.8.10 (Java-Gnome 4.0.14):
> http://www.map.ox.ac.uk/media/temp/DJI_Pf_PR.pdf
> With Cairo 1.10.2 (Java-Gnome 4.0.19):
> http://www.map.ox.ac.uk/media/temp/DJI_cairo_1-10-2.pdf

Cairo 1.10 PDF output sets the PDF interpolate flag for embedded images
based on the filter set on the pattern using cairo_pattern_set_filter().
The default filter causes the interpolate flag to be set to true.

Your PDFs contain very low resolution images that are scaled up. With
interpolate set to true you will get the blurry images. If you want the
interpolation disabled, set the filter to CAIRO_FILTER_NEAREST.

> It seems the underlying information is there as before - if I open a
> PDF in Adobe Illustrator the image is unadulterated. Also if I
> rasterize using e.g. pdftoppm the rasterization looks no different.
> Is there a way to get Cairo to embed PNGs in a way that this blurring
> doesn't happen?
> Thanks and regards,
> Will Temperley
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list