[poppler] Pink background with cairo render
Mikhail Kostousov
mikhail.kostousov at gmail.com
Fri May 2 04:30:30 PDT 2008
Hello!
I wrote a small program to split each page of pdf one in two pages. I am
using poppler_page_render to cairo surface.
The program works well, but I get pink background on page. I cannot
understand why it become pink. I am using poppler 0.8.2, cairo 1.6.4 on
macosx. The code of program
###################################
#include <stdio.h>
#include <cairo.h>
#include <cairo-pdf.h>
#include <glib/poppler.h>
int main(int argc,char **argv)
{
g_type_init();
GError * error=NULL;
gchar * uri;
uri=g_filename_to_uri(argv[1],NULL,&error);
if (error)
{
g_print("Error: %s\n",error->message);
g_error_free(error);
return 1;
}
PopplerDocument
*popplerDocument=poppler_document_new_from_file(uri,"",NULL);
if (error)
{
g_print("Error: %s\n",error->message);
g_error_free(error);
g_free(uri);
return 1;
}
int n=poppler_document_get_n_pages(popplerDocument);
double width,height;
PopplerPage *page=poppler_document_get_page(popplerDocument,2);
poppler_page_get_size(page,&width,&height);
cairo_surface_t *surface=cairo_pdf_surface_create
("test_2.pdf",width/2,height);
cairo_t *ct=cairo_create(surface);
for (int i=0;i<n;i++)
{
printf("%d from %d\n",i,n);
page=poppler_document_get_page(popplerDocument,i);
cairo_save(ct);
cairo_rectangle(ct,0,0,width/2,height);
cairo_fill(ct);
cairo_clip(ct);
poppler_page_render_for_printing(page,ct);
cairo_show_page(ct);
cairo_restore(ct);
cairo_save(ct);
cairo_translate(ct,-width/2,0);
cairo_rectangle(ct,width/2,0,width/2,height);
cairo_clip(ct);
poppler_page_render(page,ct);
cairo_show_page(ct);
cairo_restore(ct);
}
cairo_destroy(ct);
cairo_surface_finish(surface);
cairo_surface_destroy(surface);
g_free(uri);
return 0;
}
With best regards,
Mikhail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/poppler/attachments/20080502/b23b43fa/attachment-0001.htm
More information about the poppler
mailing list