[poppler] API: Help getting PDF page into pixbuf

Angus March angus at uducat.com
Fri May 1 09:39:30 PDT 2009


I might need some more help, though. I tried getting the PDF from a file
using:
    GError *error = NULL;
    PopplerDocument *pDoc = poppler_document_new_from_file(sPath, NULL,
&error);

Valgrind reports that the segmentation fault was in
poppler_document_new_from_file() in the form of:
Invalid write of size 8
at 0x71D4DC8: (within /usr/lib64/libpoppler-glib.so.4.0.0)
...
Address 0x18 is not stack'd, malloc'd or (recently) free'd

Address 0x18, eh? That doesn't seem like a likely memory address.
    This was the first call to anything Poppler in that app.


Dominic Lachowicz wrote:
> 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
>>
>>     
>
>
>
>   



More information about the poppler mailing list