[cairo] Painting PNG on PDF surface

Stefan Bellon bellon at axivion.com
Sat Oct 27 04:06:16 PDT 2007

Hi all,

upgrading to a 1.4 version of libcairo fixed my problem in
<20071026153352.1fa757bf at cube.tz.axivion.com> and works now fine on
GNU/Linux and Windows.

But on Sparc Solaris I noticed another even worse problem: The PNG
images I paint on the surface do not appear in the PDF, instead xpdf
errors about an "unknown pattern".

The code looks like this:

#include "cairo.h"

int main (void)
        cairo_surface_t *surface =
          cairo_pdf_surface_create ("hello.pdf", 640.0, 480.0);
        cairo_t *cr = cairo_create (surface);
        cairo_surface_t *image =
          cairo_image_surface_create_from_png ("small-icon.png");

        cairo_set_source_surface (cr, image, 0.0, 0.0);
        cairo_paint (cr);
        cairo_show_page (cr);

        cairo_surface_destroy (image);
        cairo_destroy (cr);
        cairo_surface_destroy (surface);

        return 0;

This code works fine on GNU/Linux and on Windows, but on Sparc Solaris
I get a PDF file which xpdf cannot correctly load:

Error: Unknown pattern 'res-4265972'
Error: Unknown pattern 'res-4265972'

I get this behaviour with cairo 1.4.6 and with cairo 1.4.10. I have
even checked with different libpng libraries in case this could be a
problem (I checked with 1.2.8 and 1.2.16).

What am I missing here?


Stefan Bellon

More information about the cairo mailing list