Hello!<br><br>I wrote a small program to split each page of pdf one in two pages. I am using poppler_page_render to cairo surface. <br>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<br>
###################################<br>#include <stdio.h><br>#include <cairo.h><br>#include <cairo-pdf.h><br>#include <glib/poppler.h><br><br><br>int main(int argc,char **argv)<br>{<br><br> g_type_init();<br>
GError * error=NULL;<br> gchar * uri;<br><br><br> uri=g_filename_to_uri(argv[1],NULL,&error);<br> if (error)<br> {<br> g_print("Error: %s\n",error->message);<br>
g_error_free(error);<br> return 1;<br> }<br><br> PopplerDocument *popplerDocument=poppler_document_new_from_file(uri,"",NULL);<br><br> if (error)<br> {<br>
g_print("Error: %s\n",error->message);<br> g_error_free(error);<br> g_free(uri);<br> return 1;<br> }<br><br> int n=poppler_document_get_n_pages(popplerDocument);<br>
<br> double width,height;<br> PopplerPage *page=poppler_document_get_page(popplerDocument,2);<br> poppler_page_get_size(page,&width,&height);<br><br> cairo_surface_t *surface=cairo_pdf_surface_create ("test_2.pdf",width/2,height);<br>
cairo_t *ct=cairo_create(surface);<br><br> for (int i=0;i<n;i++)<br> {<br><br> printf("%d from %d\n",i,n);<br> page=poppler_document_get_page(popplerDocument,i);<br>
cairo_save(ct);<br> cairo_rectangle(ct,0,0,width/2,height);<br> cairo_fill(ct);<br> cairo_clip(ct);<br> poppler_page_render_for_printing(page,ct);<br>
cairo_show_page(ct);<br> cairo_restore(ct);<br><br> cairo_save(ct);<br> cairo_translate(ct,-width/2,0);<br> cairo_rectangle(ct,width/2,0,width/2,height);<br>
cairo_clip(ct);<br> poppler_page_render(page,ct);<br> cairo_show_page(ct);<br> cairo_restore(ct);<br><br> }<br> cairo_destroy(ct);<br> cairo_surface_finish(surface);<br>
cairo_surface_destroy(surface);<br><br> g_free(uri);<br><br>return 0;<br>}<br><br><br>With best regards,<br>Mikhail<br>