[cairo] Hopefully a simple question

Carl Worth cworth at cworth.org
Mon Jun 18 12:20:59 PDT 2007

On Fri, 15 Jun 2007 15:23:54 -0500, "Ethan King" wrote:
> Please forgive my ignorance.  I was wondering if it was possible to use
> cairo to display a PDF file on the screen.  I understand that Cairo can
> output to PDF, so I guess my question is can it use a PDF as input.

The cairo library itself doesn't contain any provision for parsing a
PDF file. But you can use the poppler library to parse the pdf, and it
will in turn use cairo to do the rendering.

I've attached a simple file below that should give the idea. It uses
poppler_page_render to render to a cairo context for an image surface
and then saves the image surface as a PNG file. The same approach can
be used with a cairo context for any other surface backend.

I hope that helps.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pdf2png.c
Type: application/octet-stream
Size: 3110 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070618/2a43772e/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070618/2a43772e/attachment.pgp 

More information about the cairo mailing list