21 #ifdef HAVE_PANGOCAIRO
27 #define NUL_FILE "nul"
29 #define NUL_FILE "/dev/null"
37 static void gvloadimage_poppler_free(
usershape_t *us)
39 g_object_unref((PopplerDocument*)us->
data);
42 static PopplerDocument* gvloadimage_poppler_load(
GVJ_t * job,
usershape_t *us)
44 PopplerDocument *document =
NULL;
46 gchar *absolute, *uri;
54 if (us->
datafree == gvloadimage_poppler_free)
55 document = (PopplerDocument*)(us->
data);
70 if (g_path_is_absolute(us->
name)) {
71 absolute = g_strdup (us->
name);
73 gchar *dir = g_get_current_dir ();
74 absolute = g_build_filename (dir, us->
name, (gchar *) 0);
78 uri = g_filename_to_uri (absolute,
NULL, &error);
82 printf(
"%s\n", error->message);
86 document = poppler_document_new_from_file (uri,
NULL, &error);
87 if (document ==
NULL) {
88 printf(
"%s\n", error->message);
94 num_pages = poppler_document_get_n_pages (document);
96 printf(
"poppler fail: num_pages %d, must be at least 1", num_pages);
106 us->
data = (
void*)document;
107 us->
datafree = gvloadimage_poppler_free;
118 PopplerDocument* document = gvloadimage_poppler_load(job, us);
121 cairo_t *cr = (cairo_t *) job->
context;
122 cairo_surface_t *surface;
127 page = poppler_document_get_page (document, 0);
131 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, us->
w, us->
h);
132 cairo_surface_reference(surface);
134 cairo_set_source_surface(cr, surface, 0, 0);
135 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
136 cairo_scale(cr, (b.
UR.
x - b.
LL.
x)/(us->
w), (b.
UR.
y - b.
LL.
y)/(us->
h));
137 poppler_page_render (page, cr);
145 gvloadimage_poppler_cairo
151 #ifdef HAVE_PANGOCAIRO
153 {FORMAT_PDF_CAIRO,
"pdf:cairo", 1, &engine_cairo,
NULL},
void(* datafree)(usershape_t *us)
boolean gvusershape_file_access(usershape_t *us)
void gvusershape_file_release(usershape_t *us)
if(aagss+aagstacksize-1<=aagssp)
gvplugin_installed_t gvloadimage_poppler_types[]