- else if (pg->bg->type == BG_PIXMAP || pg->bg->type == BG_PDF) {
- if (pg->bg->type == BG_PDF) {
- pgpdf = (struct BgPdfPage *)g_list_nth_data(bgpdf.pages, pg->bg->file_page_seq-1);
- if (pgpdf == NULL) return;
- if (pgpdf->dpi != PDFTOPPM_PRINTING_DPI) {
- add_bgpdf_request(pg->bg->file_page_seq, 0, TRUE);
- while (pgpdf->dpi != PDFTOPPM_PRINTING_DPI && bgpdf.status == STATUS_RUNNING) {
- gtk_main_iteration();
- if (*abort) return;
- }
- }
- pix = pgpdf->pixbuf;
- }
- else pix = pg->bg->pixbuf;
- if (gdk_pixbuf_get_bits_per_sample(pix) != 8) return;
- if (gdk_pixbuf_get_colorspace(pix) != GDK_COLORSPACE_RGB) return;
- gnome_print_gsave(gpc);
- gnome_print_scale(gpc, pg->width, pg->height);
- gnome_print_translate(gpc, 0., -1.);
- if (gdk_pixbuf_get_n_channels(pix) == 3)
- gnome_print_rgbimage(gpc, gdk_pixbuf_get_pixels(pix),
- gdk_pixbuf_get_width(pix), gdk_pixbuf_get_height(pix), gdk_pixbuf_get_rowstride(pix));
- else if (gdk_pixbuf_get_n_channels(pix) == 4)
- gnome_print_rgbaimage(gpc, gdk_pixbuf_get_pixels(pix),
- gdk_pixbuf_get_width(pix), gdk_pixbuf_get_height(pix), gdk_pixbuf_get_rowstride(pix));
- gnome_print_grestore(gpc);
- return;
+ else
+ if (pg->bg->type == BG_PDF) {
+ if (!bgpdf.document) return;
+ pdfpage = poppler_document_get_page(bgpdf.document, pg->bg->file_page_seq-1);
+ if (!pdfpage) return;
+ poppler_page_get_size(pdfpage, &pgwidth, &pgheight);
+ cairo_save(cr);
+ cairo_scale(cr, pg->width/pgwidth, pg->height/pgheight);
+ poppler_page_render(pdfpage, cr);
+ cairo_restore(cr);
+ g_object_unref(pdfpage);
+ }
+ else
+ if (pg->bg->type == BG_PIXMAP) {
+ cairo_save(cr);
+ cairo_scale(cr, pg->width/gdk_pixbuf_get_width(pg->bg->pixbuf),
+ pg->height/gdk_pixbuf_get_height(pg->bg->pixbuf));
+ gdk_cairo_set_source_pixbuf(cr, pg->bg->pixbuf, 0, 0);
+ cairo_rectangle(cr, 0, 0, gdk_pixbuf_get_width(pg->bg->pixbuf), gdk_pixbuf_get_height(pg->bg->pixbuf));
+ cairo_fill(cr);
+ cairo_restore(cr);