[poppler] API: Help getting PDF page into pixbuf

Dominic Lachowicz domlachowicz at gmail.com
Thu Apr 30 13:26:21 PDT 2009


You can render PopplerPage objects to any Cairo surface, including
image surfaces. Here's some pseudo-code that should get you in the
right direction:

page = poppler_document_get_page();
width, height = poppler_page_get_size(page);
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo = cairo_create(surface);
poppler_page_render(page, cairo);

// do what you want with the image surface, such as write it to disk
cairo_surface_write_to_png(surface, "/home/angus/page0.png");

cairo_destroy(cairo);
cairo_surface_destroy(surface);

http://www.cairographics.org/manual/

On Thu, Apr 30, 2009 at 2:51 PM, Angus March <angus at uducat.com> wrote:
> I need to have a PDF as an image, but the API documentation is very
> sparing with information, and I have some questions:
>
>   1. Do I use poppler_page_render_selection_to_pixbuf () to do this?
>   2. Assuming 1. is true, do I get page from
>      poppler_document_new_from_file(), and the PopplerDocument instance
>      from poppler_document_new_from_file()?
>   3. How do I interpret the data in pixbuf, or is that for another manual?
>   4. Can selection be made from the data returned by
>      poppler_page_get_size()?
>   5. What's a "Poppler selection style" and what difference does it
>      make for this function?
>   6. I don't know what glyph_color and background_color should be.
>      Isn't that sort of thing native to the PDF document?
>
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
>



-- 
Mediocrity knows nothing higher than itself; but talent instantly
recognizes genius.


More information about the poppler mailing list