28 #include <poppler-document.h>
29 #include <poppler-page.h>
31 #include <cairo-pdf.h>
36 #include <glib/gi18n-lib.h>
61 #include <libxml/tree.h>
62 #include <libxml/parser.h>
63 #include <libxml/xpath.h>
64 #include <libxml/xpathInternals.h>
66 #if (defined (HAVE_CAIRO_PDF) || defined (HAVE_CAIRO_PS))
67 #define HAVE_CAIRO_PRINT
71 #define LICENSE_MARKED "/x:xmpmeta/rdf:RDF/rdf:Description/xmpRights:Marked"
72 #define LICENSE_TEXT "/x:xmpmeta/rdf:RDF/rdf:Description/dc:rights/rdf:Alt/rdf:li[lang('%s')]"
73 #define LICENSE_WEB_STATEMENT "/x:xmpmeta/rdf:RDF/rdf:Description/xmpRights:WebStatement"
75 #define LICENSE_URI "/x:xmpmeta/rdf:RDF/rdf:Description/cc:license/@rdf:resource"
88 #ifdef HAVE_CAIRO_PRINT
139 PopplerAction *action);
190 if (pdf_document->
annots) {
191 g_hash_table_destroy (pdf_document->
annots);
192 pdf_document->
annots = NULL;
196 g_object_unref (pdf_document->
document);
200 poppler_font_info_free (pdf_document->
font_info);
204 poppler_fonts_iter_free (pdf_document->
fonts_iter);
207 G_OBJECT_CLASS (pdf_document_parent_class)->dispose (
object);
220 if (poppler_error == NULL)
223 if (poppler_error->domain == POPPLER_ERROR) {
226 if (poppler_error->code == POPPLER_ERROR_INVALID)
228 else if (poppler_error->code == POPPLER_ERROR_ENCRYPTED)
231 g_set_error_literal (error,
234 poppler_error->message);
236 g_error_free (poppler_error);
238 g_propagate_error (error, poppler_error);
251 GError *poppler_error = NULL;
254 retval = poppler_document_save (pdf_document->
document,
255 uri, &poppler_error);
261 retval = poppler_document_save_a_copy (pdf_document->
document,
262 uri, &poppler_error);
276 GError *poppler_error = NULL;
280 poppler_document_new_from_file (uri, pdf_document->
password, &poppler_error);
282 if (pdf_document->
document == NULL) {
292 GInputStream *stream,
294 GCancellable *cancellable,
301 poppler_document_new_from_stream (stream, -1,
306 if (pdf_document->
document == NULL) {
318 GCancellable *cancellable,
325 poppler_document_new_from_gfile (file,
330 if (pdf_document->
document == NULL) {
341 return poppler_document_get_n_pages (
PDF_DOCUMENT (document)->document);
349 PopplerPage *poppler_page;
352 poppler_page = poppler_document_get_page (pdf_document->
document, index);
356 g_object_unref (poppler_page);
367 g_return_if_fail (POPPLER_IS_PAGE (page->
backend_page));
369 poppler_page_get_size (POPPLER_PAGE (page->
backend_page), width, height);
378 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
386 static cairo_surface_t *
392 cairo_surface_t *surface;
394 double page_width, page_height;
395 double xscale, yscale;
397 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
399 cr = cairo_create (surface);
401 switch (rc->rotation) {
403 cairo_translate (cr, width, 0);
406 cairo_translate (cr, width, height);
409 cairo_translate (cr, 0, height);
412 cairo_translate (cr, 0, 0);
415 poppler_page_get_size (page,
416 &page_width, &page_height);
419 cairo_scale (cr, xscale, yscale);
420 cairo_rotate (cr, rc->rotation * G_PI / 180.0);
421 poppler_page_render (page, cr);
423 cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
424 cairo_set_source_rgb (cr, 1., 1., 1.);
432 static cairo_surface_t *
436 PopplerPage *poppler_page;
437 double width_points, height_points;
440 poppler_page = POPPLER_PAGE (rc->page->backend_page);
442 poppler_page_get_size (poppler_page,
443 &width_points, &height_points);
458 cairo_surface_t *surface;
465 cairo_surface_destroy (surface);
474 PopplerPage *poppler_page;
475 cairo_surface_t *surface;
476 GdkPixbuf *pixbuf = NULL;
477 double page_width, page_height;
480 poppler_page = POPPLER_PAGE (rc->page->backend_page);
482 poppler_page_get_size (poppler_page,
483 &page_width, &page_height);
488 surface = poppler_page_get_thumbnail (poppler_page);
491 cairo_surface_destroy (surface);
494 if (pixbuf != NULL) {
495 int thumb_width = (rc->rotation == 90 || rc->rotation == 270) ?
496 gdk_pixbuf_get_height (pixbuf) :
497 gdk_pixbuf_get_width (pixbuf);
499 if (thumb_width == width) {
500 GdkPixbuf *rotated_pixbuf;
502 rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf,
503 (GdkPixbufRotation) (360 - rc->rotation));
504 g_object_unref (pixbuf);
505 pixbuf = rotated_pixbuf;
508 g_object_unref (pixbuf);
519 static cairo_surface_t *
524 PopplerPage *poppler_page;
525 cairo_surface_t *surface;
526 GdkPixbuf *pixbuf = NULL;
527 double page_width, page_height;
530 poppler_page = POPPLER_PAGE (rc->page->backend_page);
532 poppler_page_get_size (poppler_page,
533 &page_width, &page_height);
538 surface = poppler_page_get_thumbnail (poppler_page);
540 int surface_width = (rc->rotation == 90 || rc->rotation == 270) ?
541 cairo_image_surface_get_height (surface) :
542 cairo_image_surface_get_width (surface);
544 if (surface_width == width) {
545 cairo_surface_t *rotated_surface;
548 cairo_surface_destroy (surface);
549 return rotated_surface;
552 cairo_surface_destroy (surface);
567 xmlXPathContextPtr xpathCtx)
569 xmlXPathObjectPtr xpathObj;
570 xmlChar *part = NULL;
571 xmlChar *conf = NULL;
576 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"x", BAD_CAST
"adobe:ns:meta/");
577 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"rdf", BAD_CAST
"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
578 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"pdfaid", BAD_CAST
"http://www.aiim.org/pdfa/ns/id/");
582 xpathObj = xmlXPathEvalExpression (BAD_CAST
"/x:xmpmeta/rdf:RDF/rdf:Description/pdfaid:part", xpathCtx);
583 if (xpathObj != NULL) {
584 if (xpathObj->nodesetval != NULL && xpathObj->nodesetval->nodeNr != 0)
585 part = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
587 xmlXPathFreeObject (xpathObj);
591 xpathObj = xmlXPathEvalExpression (BAD_CAST
"/x:xmpmeta/rdf:RDF/rdf:Description/@pdfaid:part", xpathCtx);
592 if (xpathObj != NULL) {
593 if (xpathObj->nodesetval != NULL && xpathObj->nodesetval->nodeNr != 0)
594 part = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
596 xmlXPathFreeObject (xpathObj);
602 xpathObj = xmlXPathEvalExpression (BAD_CAST
"/x:xmpmeta/rdf:RDF/rdf:Description/pdfaid:conformance", xpathCtx);
603 if (xpathObj != NULL) {
604 if (xpathObj->nodesetval != NULL && xpathObj->nodesetval->nodeNr != 0)
605 conf = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
607 xmlXPathFreeObject (xpathObj);
611 xpathObj = xmlXPathEvalExpression (BAD_CAST
"/x:xmpmeta/rdf:RDF/rdf:Description/@pdfaid:conformance", xpathCtx);
612 if (xpathObj != NULL) {
613 if (xpathObj->nodesetval != NULL && xpathObj->nodesetval->nodeNr != 0)
614 conf = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
616 xmlXPathFreeObject (xpathObj);
620 if (part != NULL && conf != NULL) {
622 for (i = 0; conf[i]; i++)
623 conf[i] = g_ascii_tolower (conf[i]);
626 result = g_strdup_printf (
"PDF/A - %s%s", part, conf);
638 xmlXPathContextPtr xpathCtx)
640 xmlXPathObjectPtr xpathObj;
641 xmlChar *marked = NULL;
642 const char *language_string;
645 gchar *tag, *tag_aux;
650 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"x", BAD_CAST
"adobe:ns:meta/");
651 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"rdf", BAD_CAST
"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
652 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"dc", BAD_CAST
"http://purl.org/dc/elements/1.1/");
654 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"xmpRights", BAD_CAST
"http://ns.adobe.com/xap/1.0/rights/");
656 xmlXPathRegisterNs (xpathCtx, BAD_CAST
"cc", BAD_CAST
"http://creativecommons.org/ns#");
660 xpathObj = xmlXPathEvalExpression (BAD_CAST
LICENSE_MARKED, xpathCtx);
661 if (xpathObj != NULL) {
662 if (xpathObj->nodesetval != NULL &&
663 xpathObj->nodesetval->nodeNr != 0)
664 marked = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
665 xmlXPathFreeObject (xpathObj);
678 if (g_strrstr ((
char *) marked,
"False") != NULL) {
679 license->
text = g_strdup (
_(
"This work is in the Public Domain"));
686 language_string = pango_language_to_string (gtk_get_default_language ());
687 tags = g_strsplit (language_string,
"-", -1);
688 i = g_strv_length (tags);
689 while (i-- && !license->
text) {
690 tag = g_strdup (tags[0]);
691 for (j = 1; j <= i; j++) {
692 tag_aux = g_strdup_printf (
"%s-%s", tag, tags[j]);
697 xpathObj = xmlXPathEvalExpression (BAD_CAST aux, xpathCtx);
698 if (xpathObj != NULL) {
699 if (xpathObj->nodesetval != NULL &&
700 xpathObj->nodesetval->nodeNr != 0)
701 license->
text = (gchar *)xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
702 xmlXPathFreeObject (xpathObj);
710 if (!license->
text) {
712 xpathObj = xmlXPathEvalExpression (BAD_CAST aux, xpathCtx);
713 if (xpathObj != NULL) {
714 if (xpathObj->nodesetval != NULL &&
715 xpathObj->nodesetval->nodeNr != 0)
716 license->
text = (gchar *)xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
717 xmlXPathFreeObject (xpathObj);
725 xpathObj = xmlXPathEvalExpression (BAD_CAST
LICENSE_URI, xpathCtx);
726 if (xpathObj != NULL) {
727 if (xpathObj->nodesetval != NULL &&
728 xpathObj->nodesetval->nodeNr != 0)
729 license->
uri = (gchar *)xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
730 xmlXPathFreeObject (xpathObj);
738 if (xpathObj != NULL) {
739 if (xpathObj->nodesetval != NULL &&
740 xpathObj->nodesetval->nodeNr != 0)
741 license->
web_statement = (gchar *)xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
742 xmlXPathFreeObject (xpathObj);
760 xmlXPathContextPtr xpathCtx;
763 doc = xmlParseMemory (metadata, strlen (metadata));
767 xpathCtx = xmlXPathNewContext (doc);
768 if (xpathCtx == NULL) {
775 g_free (info->format);
781 xmlXPathFreeContext (xpathCtx);
790 PopplerPageLayout layout;
791 PopplerPageMode mode;
792 PopplerViewerPreferences view_prefs;
793 PopplerPermissions permissions;
819 "title", &(info->title),
820 "format", &(info->format),
821 "author", &(info->author),
822 "subject", &(info->subject),
823 "keywords", &(info->keywords),
825 "page-layout", &layout,
826 "viewer-preferences", &view_prefs,
827 "permissions", &permissions,
828 "creator", &(info->creator),
829 "producer", &(info->producer),
830 "creation-date", &(info->creation_date),
831 "mod-date", &(info->modified_date),
832 "linearized", &linearized,
833 "metadata", &metadata,
836 if (metadata != NULL) {
841 info->n_pages = poppler_document_get_n_pages (
PDF_DOCUMENT (document)->document);
843 if (info->n_pages > 0) {
844 PopplerPage *poppler_page;
846 poppler_page = poppler_document_get_page (
PDF_DOCUMENT (document)->document, 0);
847 poppler_page_get_size (poppler_page, &(info->paper_width), &(info->paper_height));
848 g_object_unref (poppler_page);
851 info->paper_width = info->paper_width / 72.0f * 25.4f;
852 info->paper_height = info->paper_height / 72.0f * 25.4f;
856 case POPPLER_PAGE_LAYOUT_SINGLE_PAGE:
859 case POPPLER_PAGE_LAYOUT_ONE_COLUMN:
862 case POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT:
865 case POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT:
867 case POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT:
870 case POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT:
878 case POPPLER_PAGE_MODE_NONE:
881 case POPPLER_PAGE_MODE_USE_THUMBS:
884 case POPPLER_PAGE_MODE_USE_OC:
887 case POPPLER_PAGE_MODE_FULL_SCREEN:
890 case POPPLER_PAGE_MODE_USE_ATTACHMENTS:
897 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR) {
900 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR) {
903 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI) {
906 if (view_prefs & POPPLER_VIEWER_PREFERENCES_FIT_WINDOW) {
909 if (view_prefs & POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW) {
912 if (view_prefs & POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE) {
915 if (view_prefs & POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL) {
919 info->permissions = 0;
920 if (permissions & POPPLER_PERMISSIONS_OK_TO_PRINT) {
923 if (permissions & POPPLER_PERMISSIONS_OK_TO_MODIFY) {
926 if (permissions & POPPLER_PERMISSIONS_OK_TO_COPY) {
929 if (permissions & POPPLER_PERMISSIONS_OK_TO_ADD_NOTES) {
935 info->security = g_strdup (
_(
"Yes"));
938 info->security = g_strdup (
_(
"No"));
941 info->linearized = linearized ? g_strdup (
_(
"Yes")) : g_strdup (
_(
"No"));
949 PopplerBackend backend;
951 backend = poppler_get_backend ();
953 case POPPLER_BACKEND_CAIRO:
954 info->
name =
"poppler/cairo";
956 case POPPLER_BACKEND_SPLASH:
957 info->
name =
"poppler/splash";
960 info->
name =
"poppler/unknown";
964 info->
version = poppler_get_version ();
978 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
1009 const char *password)
1016 document->
password = g_strdup (password);
1051 poppler_fonts_iter_free (pdf_document->
fonts_iter);
1056 result = poppler_font_info_scan (pdf_document->
font_info, n_pages,
1060 poppler_font_info_free (pdf_document->
font_info);
1071 case POPPLER_FONT_TYPE_TYPE1:
1073 case POPPLER_FONT_TYPE_TYPE1C:
1074 return _(
"Type 1C");
1075 case POPPLER_FONT_TYPE_TYPE3:
1077 case POPPLER_FONT_TYPE_TRUETYPE:
1078 return _(
"TrueType");
1079 case POPPLER_FONT_TYPE_CID_TYPE0:
1080 return _(
"Type 1 (CID)");
1081 case POPPLER_FONT_TYPE_CID_TYPE0C:
1082 return _(
"Type 1C (CID)");
1083 case POPPLER_FONT_TYPE_CID_TYPE2:
1084 return _(
"TrueType (CID)");
1086 return _(
"Unknown font type");
1094 static const char *base_14_subst_fonts[14] = {
1098 "Courier-BoldOblique",
1100 "Helvetica-Oblique",
1102 "Helvetica-BoldOblique",
1114 if (type != POPPLER_FONT_TYPE_TYPE1)
1117 for (i = 0; i < G_N_ELEMENTS (base_14_subst_fonts); i++) {
1118 if (g_str_equal (name, base_14_subst_fonts[i]))
1124 static const gchar *
1130 return _(
"This document contains non-embedded fonts that are not from the "
1131 "PDF Standard 14 fonts. If the substitute fonts selected by fontconfig "
1132 "are not the same as the fonts used to create the PDF, the rendering may "
1135 return _(
"All fonts are either standard or embedded.");
1140 GtkTreeModel *model)
1143 PopplerFontsIter *iter = pdf_document->
fonts_iter;
1151 GtkTreeIter list_iter;
1153 PopplerFontType type;
1154 const char *type_str;
1155 const char *embedded;
1156 const char *standard_str =
"";
1157 const gchar *substitute;
1158 const gchar *substitute_text;
1159 const gchar *filename;
1160 const gchar *encoding;
1161 const gchar *encoding_text;
1164 name = poppler_fonts_iter_get_name (iter);
1167 name =
_(
"No name");
1170 encoding = poppler_fonts_iter_get_encoding (iter);
1176 encoding =
_(
"None");
1179 type = poppler_fonts_iter_get_font_type (iter);
1182 if (poppler_fonts_iter_is_embedded (iter)) {
1183 if (poppler_fonts_iter_is_subset (iter))
1184 embedded =
_(
"Embedded subset");
1186 embedded =
_(
"Embedded");
1188 embedded =
_(
"Not embedded");
1195 standard_str =
_(
" (One of the Standard 14 Fonts)");
1202 standard_str =
_(
" (Not one of the Standard 14 Fonts)");
1207 substitute = poppler_fonts_iter_get_substitute_name (iter);
1208 filename = poppler_fonts_iter_get_file_name (iter);
1209 encoding_text =
_(
"Encoding");
1210 substitute_text =
_(
"Substituting with");
1212 if (substitute && filename)
1213 details = g_markup_printf_escaped (
"%s%s\n%s: %s\n%s\n%s <b>%s</b>\n(%s)",
1214 type_str, standard_str,
1215 encoding_text, encoding, embedded,
1216 substitute_text, substitute, filename);
1218 details = g_markup_printf_escaped (
"%s%s\n%s: %s\n%s",
1219 type_str, standard_str,
1220 encoding_text, encoding, embedded);
1222 gtk_list_store_append (GTK_LIST_STORE (model), &list_iter);
1223 gtk_list_store_set (GTK_LIST_STORE (model), &list_iter,
1229 }
while (poppler_fonts_iter_next (iter));
1245 PopplerIndexIter *iter;
1249 iter = poppler_index_iter_new (pdf_document->
document);
1252 poppler_index_iter_free (iter);
1262 const char *unimplemented_dest = NULL;
1264 g_assert (dest != NULL);
1266 switch (dest->type) {
1267 case POPPLER_DEST_XYZ: {
1268 PopplerPage *poppler_page;
1271 poppler_page = poppler_document_get_page (pdf_document->
document,
1272 MAX (0, dest->page_num - 1));
1273 poppler_page_get_size (poppler_page, NULL, &height);
1276 height - MIN (height, dest->top),
1281 g_object_unref (poppler_page);
1284 case POPPLER_DEST_FITB:
1285 case POPPLER_DEST_FIT:
1288 case POPPLER_DEST_FITBH:
1289 case POPPLER_DEST_FITH: {
1290 PopplerPage *poppler_page;
1293 poppler_page = poppler_document_get_page (pdf_document->
document,
1294 MAX (0, dest->page_num - 1));
1295 poppler_page_get_size (poppler_page, NULL, &height);
1297 height - MIN (height, dest->top),
1299 g_object_unref (poppler_page);
1302 case POPPLER_DEST_FITBV:
1303 case POPPLER_DEST_FITV:
1308 case POPPLER_DEST_FITR: {
1309 PopplerPage *poppler_page;
1312 poppler_page = poppler_document_get_page (pdf_document->
document,
1313 MAX (0, dest->page_num - 1));
1314 poppler_page_get_size (poppler_page, NULL, &height);
1318 MIN (dest->left, dest->right),
1319 height - MIN (height, MIN (dest->bottom, dest->top)),
1320 MAX (dest->left, dest->right),
1321 height - MIN (height, MAX (dest->bottom, dest->top)));
1322 g_object_unref (poppler_page);
1325 case POPPLER_DEST_NAMED:
1328 case POPPLER_DEST_UNKNOWN:
1329 unimplemented_dest =
"POPPLER_DEST_UNKNOWN";
1333 if (unimplemented_dest) {
1334 g_warning (
"Unimplemented destination: %s, please post a "
1335 "bug report in Evince bugzilla "
1336 "(http://bugzilla.gnome.org) with a testcase.",
1337 unimplemented_dest);
1348 PopplerAction *action)
1352 const char *unimplemented_action = NULL;
1354 switch (action->type) {
1355 case POPPLER_ACTION_NONE:
1357 case POPPLER_ACTION_GOTO_DEST: {
1362 g_object_unref (dest);
1365 case POPPLER_ACTION_GOTO_REMOTE: {
1370 action->goto_remote.file_name);
1371 g_object_unref (dest);
1375 case POPPLER_ACTION_LAUNCH:
1377 action->launch.params);
1379 case POPPLER_ACTION_URI:
1382 case POPPLER_ACTION_NAMED:
1385 case POPPLER_ACTION_MOVIE:
1386 unimplemented_action =
"POPPLER_ACTION_MOVIE";
1388 case POPPLER_ACTION_RENDITION:
1389 unimplemented_action =
"POPPLER_ACTION_RENDITION";
1391 case POPPLER_ACTION_OCG_STATE: {
1392 GList *on_list = NULL;
1393 GList *off_list = NULL;
1394 GList *toggle_list = NULL;
1397 for (l = action->ocg_state.state_list; l; l = g_list_next (l)) {
1398 PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data;
1400 for (m = action_layer->layers; m; m = g_list_next (m)) {
1401 PopplerLayer *layer = (PopplerLayer *)m->data;
1404 ev_layer =
ev_layer_new (poppler_layer_is_parent (layer),
1405 poppler_layer_get_radio_button_group_id (layer));
1406 g_object_set_data_full (G_OBJECT (ev_layer),
1408 g_object_ref (layer),
1409 (GDestroyNotify)g_object_unref);
1411 switch (action_layer->action) {
1412 case POPPLER_ACTION_LAYER_ON:
1413 on_list = g_list_prepend (on_list, ev_layer);
1415 case POPPLER_ACTION_LAYER_OFF:
1416 off_list = g_list_prepend (off_list, ev_layer);
1418 case POPPLER_ACTION_LAYER_TOGGLE:
1419 toggle_list = g_list_prepend (toggle_list, ev_layer);
1427 g_list_reverse (off_list),
1428 g_list_reverse (toggle_list));
1433 case POPPLER_ACTION_JAVASCRIPT:
1434 unimplemented_action =
"POPPLER_ACTION_JAVASCRIPT";
1436 case POPPLER_ACTION_UNKNOWN:
1437 unimplemented_action =
"POPPLER_ACTION_UNKNOWN";
1440 if (unimplemented_action) {
1441 g_warning (
"Unimplemented action: %s, please post a bug report "
1442 "in Evince bugzilla (http://bugzilla.gnome.org) "
1443 "with a testcase.", unimplemented_action);
1446 link =
ev_link_new (action->any.title, ev_action);
1448 g_object_unref (ev_action);
1455 GtkTreeModel *model,
1456 GtkTreeIter *parent,
1457 PopplerIndexIter *iter)
1461 GtkTreeIter tree_iter;
1462 PopplerIndexIter *child;
1463 PopplerAction *action;
1468 action = poppler_index_iter_get_action (iter);
1469 expand = poppler_index_iter_is_open (iter);
1476 poppler_action_free (action);
1478 g_object_unref (link);
1483 gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
1486 gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
1492 g_free (title_markup);
1493 g_object_unref (link);
1495 child = poppler_index_iter_get_child (iter);
1497 build_tree (pdf_document, model, &tree_iter, child);
1498 poppler_index_iter_free (child);
1499 poppler_action_free (action);
1501 }
while (poppler_index_iter_next (iter));
1504 static GtkTreeModel *
1508 GtkTreeModel *model = NULL;
1509 PopplerIndexIter *iter;
1513 iter = poppler_index_iter_new (pdf_document->
document);
1521 build_tree (pdf_document, model, NULL, iter);
1522 poppler_index_iter_free (iter);
1533 PopplerPage *poppler_page;
1534 GList *retval = NULL;
1535 GList *mapping_list;
1541 mapping_list = poppler_page_get_link_mapping (poppler_page);
1542 poppler_page_get_size (poppler_page, NULL, &height);
1544 for (list = mapping_list; list; list = list->next) {
1545 PopplerLinkMapping *link_mapping;
1548 link_mapping = (PopplerLinkMapping *)list->
data;
1551 link_mapping->action);
1552 ev_link_mapping->
area.
x1 = link_mapping->area.x1;
1553 ev_link_mapping->
area.
x2 = link_mapping->area.x2;
1555 ev_link_mapping->
area.
y1 = height - link_mapping->area.y2;
1556 ev_link_mapping->
area.
y2 = height - link_mapping->area.y1;
1558 retval = g_list_prepend (retval, ev_link_mapping);
1561 poppler_page_free_link_mapping (mapping_list);
1568 const gchar *link_name)
1575 dest = poppler_document_find_dest (pdf_document->
document,
1579 poppler_dest_free (dest);
1587 const gchar *link_name)
1594 dest = poppler_document_find_dest (pdf_document->
document,
1597 retval = dest->page_num - 1;
1598 poppler_dest_free (dest);
1618 GList *retval = NULL;
1619 PopplerPage *poppler_page;
1620 GList *mapping_list;
1624 mapping_list = poppler_page_get_image_mapping (poppler_page);
1626 for (list = mapping_list; list; list = list->next) {
1627 PopplerImageMapping *image_mapping;
1630 image_mapping = (PopplerImageMapping *)list->
data;
1632 ev_image_mapping = g_new (
EvMapping, 1);
1635 ev_image_mapping->
area.
x1 = image_mapping->area.x1;
1636 ev_image_mapping->
area.
y1 = image_mapping->area.y1;
1637 ev_image_mapping->
area.
x2 = image_mapping->area.x2;
1638 ev_image_mapping->
area.
y2 = image_mapping->area.y2;
1640 retval = g_list_prepend (retval, ev_image_mapping);
1643 poppler_page_free_image_mapping (mapping_list);
1652 GdkPixbuf *retval = NULL;
1654 PopplerPage *poppler_page;
1655 cairo_surface_t *surface;
1658 poppler_page = poppler_document_get_page (pdf_document->
document,
1661 surface = poppler_page_get_image (poppler_page,
ev_image_get_id (image));
1664 cairo_surface_destroy (surface);
1667 g_object_unref (poppler_page);
1686 PopplerPage *poppler_page;
1688 GList *retval = NULL;
1689 guint find_flags = 0;
1691 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
1692 g_return_val_if_fail (text != NULL, NULL);
1697 find_flags |= POPPLER_FIND_CASE_SENSITIVE;
1699 find_flags |= POPPLER_FIND_WHOLE_WORDS_ONLY;
1700 matches = poppler_page_find_text_with_options (poppler_page, text, (PopplerFindFlags)find_flags);
1704 poppler_page_get_size (poppler_page, NULL, &height);
1705 for (l = matches; l && l->data; l = g_list_next (l)) {
1706 PopplerRectangle *rect = (PopplerRectangle *)l->data;
1710 ev_rect->
x1 = rect->x1;
1711 ev_rect->x2 = rect->x2;
1713 ev_rect->y1 = height - rect->y2;
1714 ev_rect->y2 = height - rect->y1;
1716 retval = g_list_prepend (retval, ev_rect);
1719 g_list_foreach (matches, (GFunc)poppler_rectangle_free, NULL);
1720 g_list_free (matches);
1722 return g_list_reverse (retval);
1729 gboolean case_sensitive)
1759 #ifdef HAVE_CAIRO_PRINT
1761 cairo_destroy (ctx->cr);
1766 poppler_ps_file_free (ctx->
ps_file);
1779 #ifdef HAVE_CAIRO_PRINT
1780 cairo_surface_t *surface = NULL;
1789 #ifdef HAVE_CAIRO_PRINT
1827 #ifdef HAVE_CAIRO_PS
1832 #ifdef HAVE_CAIRO_PDF
1837 g_assert_not_reached ();
1840 ctx->cr = cairo_create (surface);
1841 cairo_surface_destroy (surface);
1860 g_return_if_fail (pdf_document->
print_ctx != NULL);
1864 #ifdef HAVE_CAIRO_PRINT
1867 cairo_ps_surface_set_size (cairo_get_target (ctx->cr),
1871 cairo_pdf_surface_set_size (cairo_get_target (ctx->cr),
1885 PopplerPage *poppler_page;
1886 #ifdef HAVE_CAIRO_PRINT
1887 gdouble page_width, page_height;
1890 gdouble width, height;
1891 gdouble pwidth, pheight;
1892 gdouble xscale, yscale;
1895 g_return_if_fail (pdf_document->
print_ctx != NULL);
1897 poppler_page = POPPLER_PAGE (rc->page->backend_page);
1899 #ifdef HAVE_CAIRO_PRINT
1902 poppler_page_get_size (poppler_page, &page_width, &page_height);
1904 if (page_width > page_height && page_width > ctx->
paper_width) {
1933 page_width = page_height;
1937 pwidth = width / ctx->
pages_x;
1938 pheight = height / ctx->
pages_y;
1940 if ((page_width > pwidth || page_height > pheight) ||
1941 (page_width < pwidth && page_height < pheight)) {
1942 xscale = pwidth / page_width;
1943 yscale = pheight / page_height;
1945 if (yscale < xscale) {
1952 xscale = yscale = 1;
1957 cairo_save (ctx->cr);
1959 cairo_matrix_t matrix;
1961 cairo_translate (ctx->cr, (2 * y + 1) * pwidth, 0);
1962 cairo_matrix_init (&matrix,
1966 cairo_transform (ctx->cr, &matrix);
1969 cairo_translate (ctx->cr,
1970 x * (rotate ? pheight : pwidth),
1971 y * (rotate ? pwidth : pheight));
1972 cairo_scale (ctx->cr, xscale, yscale);
1974 poppler_page_render_for_printing (poppler_page, ctx->cr);
1978 cairo_restore (ctx->cr);
1981 poppler_page_render_to_ps (poppler_page, ctx->
ps_file);
1991 g_return_if_fail (pdf_document->
print_ctx != NULL);
1993 #ifdef HAVE_CAIRO_PRINT
1994 cairo_show_page (ctx->cr);
2016 #ifdef HAVE_CAIRO_PRINT
2020 #ifdef HAVE_CAIRO_PDF
2043 poppler_page_render_for_printing (POPPLER_PAGE (page->
backend_page), cr);
2055 cairo_surface_t **surface,
2062 PopplerPage *poppler_page;
2064 PopplerColor text_color, base_color;
2065 double width_points, height_points;
2067 double xscale, yscale;
2069 poppler_page = POPPLER_PAGE (rc->page->backend_page);
2071 poppler_page_get_size (poppler_page,
2072 &width_points, &height_points);
2075 text_color.red = text->red;
2076 text_color.green = text->green;
2077 text_color.blue = text->blue;
2079 base_color.red = base->red;
2080 base_color.green = base->green;
2081 base_color.blue = base->blue;
2083 if (*surface == NULL) {
2084 *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
2089 cr = cairo_create (*surface);
2091 cairo_scale (cr, xscale, yscale);
2092 cairo_surface_set_device_offset (*surface, 0, 0);
2093 memset (cairo_image_surface_get_data (*surface), 0x00,
2094 cairo_image_surface_get_height (*surface) *
2095 cairo_image_surface_get_stride (*surface));
2096 poppler_page_render_selection (poppler_page,
2098 (PopplerRectangle *)points,
2099 (PopplerRectangle *)old_points,
2100 (PopplerSelectionStyle)style,
2112 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
2114 return poppler_page_get_selected_text (POPPLER_PAGE (page->
backend_page),
2115 (PopplerSelectionStyle)style,
2116 (PopplerRectangle *)points);
2119 static cairo_region_t *
2123 cairo_region_t *retval;
2125 retval = cairo_region_create ();
2127 for (l = region; l; l = g_list_next (l)) {
2128 PopplerRectangle *rectangle;
2129 cairo_rectangle_int_t rect;
2131 rectangle = (PopplerRectangle *)l->data;
2133 rect.x = (gint) ((rectangle->x1 * xscale) + 0.5);
2134 rect.y = (gint) ((rectangle->y1 * yscale) + 0.5);
2135 rect.width = (gint) ((rectangle->x2 * xscale) + 0.5) - rect.x;
2136 rect.height = (gint) ((rectangle->y2 * yscale) + 0.5) - rect.y;
2137 cairo_region_union_rectangle (retval, &rect);
2139 poppler_rectangle_free (rectangle);
2145 static cairo_region_t *
2151 PopplerPage *poppler_page;
2152 cairo_region_t *retval;
2154 double page_width, page_height;
2155 double xscale, yscale;
2157 poppler_page = POPPLER_PAGE (rc->page->backend_page);
2158 region = poppler_page_get_selection_region (poppler_page,
2160 (PopplerSelectionStyle)style,
2161 (PopplerRectangle *) points);
2162 poppler_page_get_size (poppler_page,
2163 &page_width, &page_height);
2166 g_list_free (region);
2181 static cairo_region_t *
2185 PopplerPage *poppler_page;
2186 PopplerRectangle points;
2188 cairo_region_t *retval;
2190 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
2196 poppler_page_get_size (poppler_page, &(points.x2), &(points.y2));
2198 region = poppler_page_get_selection_region (poppler_page, 1.0,
2199 POPPLER_SELECTION_GLYPH,
2202 g_list_free (region);
2211 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
2213 return poppler_page_get_text (POPPLER_PAGE (page->
backend_page));
2224 return poppler_page_get_text_layout (POPPLER_PAGE (page->
backend_page),
2225 (PopplerRectangle **)areas, n_areas);
2228 static PangoAttrList *
2232 GList *backend_attrs_list, *l;
2233 PangoAttrList *attrs_list;
2235 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
2237 backend_attrs_list = poppler_page_get_text_attributes (POPPLER_PAGE (page->
backend_page));
2238 if (!backend_attrs_list)
2241 attrs_list = pango_attr_list_new ();
2242 for (l = backend_attrs_list; l; l = g_list_next (l)) {
2243 PopplerTextAttributes *backend_attrs = (PopplerTextAttributes *)l->data;
2244 PangoAttribute *attr;
2246 if (backend_attrs->is_underlined) {
2247 attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
2248 attr->start_index = backend_attrs->start_index;
2249 attr->end_index = backend_attrs->end_index;
2250 pango_attr_list_insert (attrs_list, attr);
2253 attr = pango_attr_foreground_new (backend_attrs->color.red,
2254 backend_attrs->color.green,
2255 backend_attrs->color.blue);
2256 attr->start_index = backend_attrs->start_index;
2257 attr->end_index = backend_attrs->end_index;
2258 pango_attr_list_insert (attrs_list, attr);
2260 if (backend_attrs->font_name) {
2261 attr = pango_attr_family_new (backend_attrs->font_name);
2262 attr->start_index = backend_attrs->start_index;
2263 attr->end_index = backend_attrs->end_index;
2264 pango_attr_list_insert (attrs_list, attr);
2267 if (backend_attrs->font_size) {
2268 attr = pango_attr_size_new (backend_attrs->font_size * PANGO_SCALE);
2269 attr->start_index = backend_attrs->start_index;
2270 attr->end_index = backend_attrs->end_index;
2271 pango_attr_list_insert (attrs_list, attr);
2275 poppler_page_free_text_attributes (backend_attrs_list);
2295 PopplerPage *poppler_page;
2296 gdouble duration = -1;
2299 poppler_page = poppler_document_get_page (pdf_document->
document, page);
2303 duration = poppler_page_get_duration (poppler_page);
2304 g_object_unref (poppler_page);
2314 PopplerPage *poppler_page;
2315 PopplerPageTransition *page_transition;
2319 poppler_page = poppler_document_get_page (pdf_document->
document, page);
2324 page_transition = poppler_page_get_transition (poppler_page);
2326 if (!page_transition) {
2327 g_object_unref (poppler_page);
2333 "alignment", page_transition->alignment,
2334 "direction", page_transition->direction,
2335 "duration", page_transition->duration,
2336 "angle", page_transition->angle,
2337 "scale", page_transition->scale,
2338 "rectangular", page_transition->rectangular,
2341 poppler_page_transition_free (page_transition);
2342 g_object_unref (poppler_page);
2357 pdf_document_get_crop_box (
EvDocument *document,
2362 PopplerPage *poppler_page;
2363 PopplerRectangle poppler_rect;
2366 poppler_page = poppler_document_get_page (pdf_document->
document, page);
2367 poppler_page_get_crop_box (poppler_page, &poppler_rect);
2368 rect->
x1 = poppler_rect.x1;
2369 rect->
x2 = poppler_rect.x2;
2370 rect->
y1 = poppler_rect.y1;
2371 rect->
y2 = poppler_rect.y2;
2377 PopplerFormField *poppler_field)
2382 gboolean is_read_only;
2383 PopplerAction *action;
2385 id = poppler_form_field_get_id (poppler_field);
2386 font_size = poppler_form_field_get_font_size (poppler_field);
2387 is_read_only = poppler_form_field_is_read_only (poppler_field);
2388 action = poppler_form_field_get_action (poppler_field);
2390 switch (poppler_form_field_get_field_type (poppler_field)) {
2391 case POPPLER_FORM_FIELD_TEXT: {
2395 switch (poppler_form_field_text_get_text_type (poppler_field)) {
2396 case POPPLER_FORM_TEXT_NORMAL:
2399 case POPPLER_FORM_TEXT_MULTILINE:
2402 case POPPLER_FORM_TEXT_FILE_SELECT:
2410 field_text->
do_spell_check = poppler_form_field_text_do_spell_check (poppler_field);
2411 field_text->
do_scroll = poppler_form_field_text_do_scroll (poppler_field);
2412 field_text->
is_rich_text = poppler_form_field_text_is_rich_text (poppler_field);
2413 field_text->
is_password = poppler_form_field_text_is_password (poppler_field);
2414 field_text->
max_len = poppler_form_field_text_get_max_len (poppler_field);
2415 field_text->
text = poppler_form_field_text_get_text (poppler_field);
2419 case POPPLER_FORM_FIELD_BUTTON: {
2423 switch (poppler_form_field_button_get_button_type (poppler_field)) {
2424 case POPPLER_FORM_BUTTON_PUSH:
2427 case POPPLER_FORM_BUTTON_CHECK:
2430 case POPPLER_FORM_BUTTON_RADIO:
2438 field_button->
state = poppler_form_field_button_get_state (poppler_field);
2441 case POPPLER_FORM_FIELD_CHOICE: {
2445 switch (poppler_form_field_choice_get_choice_type (poppler_field)) {
2446 case POPPLER_FORM_CHOICE_COMBO:
2457 field_choice->
is_editable = poppler_form_field_choice_is_editable (poppler_field);
2458 field_choice->
multi_select = poppler_form_field_choice_can_select_multiple (poppler_field);
2459 field_choice->
do_spell_check = poppler_form_field_choice_do_spell_check (poppler_field);
2460 field_choice->
commit_on_sel_change = poppler_form_field_choice_commit_on_change (poppler_field);
2465 field_choice->
text = poppler_form_field_choice_get_text (poppler_field);
2468 case POPPLER_FORM_FIELD_SIGNATURE:
2472 case POPPLER_FORM_FIELD_UNKNOWN:
2489 PopplerPage *poppler_page;
2490 GList *retval = NULL;
2495 g_return_val_if_fail (POPPLER_IS_PAGE (page->
backend_page), NULL);
2498 fields = poppler_page_get_form_field_mapping (poppler_page);
2499 poppler_page_get_size (poppler_page, NULL, &height);
2501 for (list = fields; list; list = list->next) {
2502 PopplerFormFieldMapping *mapping;
2506 mapping = (PopplerFormFieldMapping *)list->data;
2513 field_mapping->
area.
x1 = mapping->area.x1;
2514 field_mapping->
area.
x2 = mapping->area.x2;
2515 field_mapping->
area.
y1 = height - mapping->area.y2;
2516 field_mapping->
area.
y2 = height - mapping->area.y1;
2517 field_mapping->
data = ev_field;
2520 g_object_set_data_full (G_OBJECT (ev_field),
2522 g_object_ref (mapping->field),
2523 (GDestroyNotify) g_object_unref);
2525 retval = g_list_prepend (retval, field_mapping);
2528 poppler_page_free_form_field_mapping (fields);
2531 g_list_reverse (retval),
2532 (GDestroyNotify)g_object_unref) : NULL;
2546 PopplerFormField *poppler_field;
2549 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2553 text = poppler_form_field_text_get_text (poppler_field);
2563 PopplerFormField *poppler_field;
2565 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2569 poppler_form_field_text_set_text (poppler_field, text);
2578 PopplerFormField *poppler_field;
2580 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2584 poppler_form_field_button_set_state (poppler_field, state);
2592 PopplerFormField *poppler_field;
2595 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2599 state = poppler_form_field_button_get_state (poppler_field);
2609 PopplerFormField *poppler_field;
2612 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2616 text = poppler_form_field_choice_get_item (poppler_field, index);
2625 PopplerFormField *poppler_field;
2628 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2632 n_items = poppler_form_field_choice_get_n_items (poppler_field);
2642 PopplerFormField *poppler_field;
2645 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2649 selected = poppler_form_field_choice_is_item_selected (poppler_field, index);
2659 PopplerFormField *poppler_field;
2661 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2665 poppler_form_field_choice_select_item (poppler_field, index);
2674 PopplerFormField *poppler_field;
2676 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2680 poppler_form_field_choice_toggle_item (poppler_field, index);
2688 PopplerFormField *poppler_field;
2690 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2694 poppler_form_field_choice_unselect_all (poppler_field);
2703 PopplerFormField *poppler_field;
2705 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2709 poppler_form_field_choice_set_text (poppler_field, text);
2717 PopplerFormField *poppler_field;
2720 poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field),
"poppler-field"));
2724 text = poppler_form_field_choice_get_text (poppler_field);
2753 PopplerColor *poppler_color;
2755 poppler_color = poppler_annot_get_color (poppler_annot);
2756 if (poppler_color) {
2757 color->red = poppler_color->red;
2758 color->green = poppler_color->green;
2759 color->blue = poppler_color->blue;
2761 g_free (poppler_color);
2768 gchar *icon = poppler_annot_text_get_icon (poppler_annot);
2774 if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_NOTE) == 0)
2776 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_COMMENT) == 0)
2778 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_KEY) == 0)
2780 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_HELP) == 0)
2782 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH) == 0)
2784 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_PARAGRAPH) == 0)
2786 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_INSERT) == 0)
2788 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_CROSS) == 0)
2790 else if (strcmp (icon, POPPLER_ANNOT_TEXT_ICON_CIRCLE) == 0)
2800 static const gchar *
2805 return POPPLER_ANNOT_TEXT_ICON_NOTE;
2807 return POPPLER_ANNOT_TEXT_ICON_COMMENT;
2809 return POPPLER_ANNOT_TEXT_ICON_KEY;
2811 return POPPLER_ANNOT_TEXT_ICON_HELP;
2813 return POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH;
2815 return POPPLER_ANNOT_TEXT_ICON_PARAGRAPH;
2817 return POPPLER_ANNOT_TEXT_ICON_INSERT;
2819 return POPPLER_ANNOT_TEXT_ICON_CROSS;
2821 return POPPLER_ANNOT_TEXT_ICON_CIRCLE;
2824 return POPPLER_ANNOT_TEXT_ICON_NOTE;
2831 switch (poppler_annot_get_annot_type (poppler_annot)) {
2832 case POPPLER_ANNOT_TEXT:
2833 case POPPLER_ANNOT_LINE:
2834 case POPPLER_ANNOT_SQUARE:
2835 case POPPLER_ANNOT_CIRCLE:
2836 case POPPLER_ANNOT_POLYGON:
2837 case POPPLER_ANNOT_POLY_LINE:
2838 case POPPLER_ANNOT_HIGHLIGHT:
2839 case POPPLER_ANNOT_UNDERLINE:
2840 case POPPLER_ANNOT_SQUIGGLY:
2841 case POPPLER_ANNOT_STRIKE_OUT:
2842 case POPPLER_ANNOT_STAMP:
2843 case POPPLER_ANNOT_CARET:
2844 case POPPLER_ANNOT_INK:
2845 case POPPLER_ANNOT_FILE_ATTACHMENT:
2857 const gchar *unimplemented_annot = NULL;
2858 gboolean reported_annot =
FALSE;
2860 switch (poppler_annot_get_annot_type (poppler_annot)) {
2861 case POPPLER_ANNOT_TEXT: {
2862 PopplerAnnotText *poppler_text;
2865 poppler_text = POPPLER_ANNOT_TEXT (poppler_annot);
2871 poppler_annot_text_get_is_open (poppler_text));
2875 case POPPLER_ANNOT_FILE_ATTACHMENT: {
2876 PopplerAnnotFileAttachment *poppler_annot_attachment;
2877 PopplerAttachment *poppler_attachment;
2880 GError *error = NULL;
2882 poppler_annot_attachment = POPPLER_ANNOT_FILE_ATTACHMENT (poppler_annot);
2883 poppler_attachment = poppler_annot_file_attachment_get_attachment (poppler_annot_attachment);
2885 if (poppler_attachment &&
2890 poppler_attachment->description,
2891 poppler_attachment->mtime,
2892 poppler_attachment->ctime,
2895 g_object_unref (ev_attachment);
2897 g_warning (
"%s", error->message);
2898 g_error_free (error);
2901 if (poppler_attachment)
2902 g_object_unref (poppler_attachment);
2905 case POPPLER_ANNOT_HIGHLIGHT:
2908 case POPPLER_ANNOT_STRIKE_OUT:
2911 case POPPLER_ANNOT_UNDERLINE:
2914 case POPPLER_ANNOT_SQUIGGLY:
2917 case POPPLER_ANNOT_LINK:
2918 case POPPLER_ANNOT_WIDGET:
2919 case POPPLER_ANNOT_MOVIE:
2922 case POPPLER_ANNOT_SCREEN: {
2923 PopplerAction *action;
2926 action = poppler_annot_screen_get_action (POPPLER_ANNOT_SCREEN (poppler_annot));
2927 if (action && action->type == POPPLER_ACTION_RENDITION)
2931 case POPPLER_ANNOT_3D:
2932 case POPPLER_ANNOT_CARET:
2933 case POPPLER_ANNOT_FREE_TEXT:
2934 case POPPLER_ANNOT_LINE:
2935 case POPPLER_ANNOT_SOUND:
2936 case POPPLER_ANNOT_SQUARE:
2937 case POPPLER_ANNOT_STAMP: {
2943 GEnumValue *enum_value;
2944 reported_annot =
TRUE;
2946 enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_ANNOT_TYPE),
2947 poppler_annot_get_annot_type (poppler_annot));
2948 unimplemented_annot = enum_value ? enum_value->value_name :
"Unknown annotation";
2952 GEnumValue *enum_value;
2953 reported_annot =
FALSE;
2955 enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_ANNOT_TYPE),
2956 poppler_annot_get_annot_type (poppler_annot));
2957 unimplemented_annot = enum_value ? enum_value->value_name :
"Unknown annotation";
2961 if (unimplemented_annot) {
2962 if (reported_annot) {
2963 g_warning (
"Unimplemented annotation: %s. It is a known issue "
2964 "and it might be implemented in the future.",
2965 unimplemented_annot);
2967 g_warning (
"Unimplemented annotation: %s, please post a "
2968 "bug report in Evince bugzilla "
2969 "(http://bugzilla.gnome.org) with a testcase.",
2970 unimplemented_annot);
2981 contents = poppler_annot_get_contents (poppler_annot);
2987 name = poppler_annot_get_name (poppler_annot);
2993 modified = poppler_annot_get_modified (poppler_annot);
2994 if (poppler_date_parse (modified, &utime)) {
3005 PopplerAnnotMarkup *markup;
3008 PopplerRectangle poppler_rect;
3010 markup = POPPLER_ANNOT_MARKUP (poppler_annot);
3012 if (poppler_annot_markup_get_popup_rectangle (markup, &poppler_rect)) {
3017 poppler_page_get_size (POPPLER_PAGE (page->
backend_page),
3019 ev_rect.
x1 = poppler_rect.x1;
3020 ev_rect.
x2 = poppler_rect.x2;
3021 ev_rect.
y1 = height - poppler_rect.y2;
3022 ev_rect.
y2 = height - poppler_rect.y1;
3024 is_open = poppler_annot_markup_get_popup_is_open (markup);
3026 g_object_set (ev_annot,
3027 "rectangle", &ev_rect,
3028 "popup_is_open", is_open,
3032 g_object_set (ev_annot,
3037 label = poppler_annot_markup_get_label (markup);
3038 opacity = poppler_annot_markup_get_opacity (markup);
3040 g_object_set (ev_annot,
3043 "can_have_popup",
TRUE,
3058 name = g_strdup_printf (
"annot-%" G_GUINT64_FORMAT, g_get_real_time ());
3075 GList *retval = NULL;
3077 PopplerPage *poppler_page;
3087 if (pdf_document->
annots) {
3089 GINT_TO_POINTER (page->
index));
3094 annots = poppler_page_get_annot_mapping (poppler_page);
3095 poppler_page_get_size (poppler_page, NULL, &height);
3097 for (list = annots; list; list = list->next) {
3098 PopplerAnnotMapping *mapping;
3102 mapping = (PopplerAnnotMapping *)list->data;
3117 annot_mapping->
area.
x1 = mapping->area.x1;
3119 annot_mapping->
area.
y1 = height - mapping->area.y2;
3120 annot_mapping->
area.
y2 = MIN(height, annot_mapping->
area.
y1 + 24);
3122 annot_mapping->
area.
x1 = mapping->area.x1;
3123 annot_mapping->
area.
x2 = mapping->area.x2;
3124 annot_mapping->
area.
y1 = height - mapping->area.y2;
3125 annot_mapping->
area.
y2 = height - mapping->area.y1;
3127 annot_mapping->
data = ev_annot;
3129 g_signal_connect (ev_annot,
"notify::area",
3133 g_object_set_data_full (G_OBJECT (ev_annot),
3135 g_object_ref (mapping->annot),
3136 (GDestroyNotify) g_object_unref);
3138 retval = g_list_prepend (retval, annot_mapping);
3141 poppler_page_free_annot_mapping (annots);
3146 if (!pdf_document->
annots) {
3147 pdf_document->
annots = g_hash_table_new_full (g_direct_hash,
3149 (GDestroyNotify)NULL,
3154 g_hash_table_insert (pdf_document->
annots,
3155 GINT_TO_POINTER (page->
index),
3158 return mapping_list;
3164 return PDF_DOCUMENT (document_annotations)->annots_modified;
3171 PopplerPage *poppler_page;
3174 PopplerAnnot *poppler_annot;
3179 poppler_annot = POPPLER_ANNOT (g_object_get_data (G_OBJECT (annot),
"poppler-annot"));
3184 poppler_page_remove_annot (poppler_page, poppler_annot);
3188 GINT_TO_POINTER (page->
index));
3193 g_hash_table_remove (pdf_document->
annots, GINT_TO_POINTER (page->
index));
3203 PopplerRectangle *bbox)
3210 gdouble max_x, max_y, min_x, min_y;
3213 bbox->x1 = G_MAXDOUBLE;
3214 bbox->y1 = G_MAXDOUBLE;
3215 bbox->x2 = G_MINDOUBLE;
3216 bbox->y2 = G_MINDOUBLE;
3219 poppler_page_get_size (page, NULL, &height);
3221 rects = poppler_page_get_selection_region (page, 1.0, POPPLER_SELECTION_GLYPH,
3222 (PopplerRectangle *)area);
3223 n_rects = g_list_length (rects);
3225 quads = g_array_sized_new (
TRUE,
TRUE,
3226 sizeof (PopplerQuadrilateral),
3228 g_array_set_size (quads, MAX (1, n_rects));
3230 for (l = rects, i = 0; i < n_rects; i++, l = l->next) {
3231 PopplerRectangle *r = (PopplerRectangle *) l->data;
3232 PopplerQuadrilateral *quad = &g_array_index (quads, PopplerQuadrilateral, i);
3235 quad->p1.y = height - r->y1;
3237 quad->p2.y = height - r->y1;
3239 quad->p3.y = height - r->y2;
3241 quad->p4.y = height - r->y2;
3242 poppler_rectangle_free (r);
3247 max_x = MAX (quad->p1.x, MAX (quad->p2.x, MAX (quad->p3.x, quad->p4.x)));
3248 max_y = MAX (quad->p1.y, MAX (quad->p2.y, MAX (quad->p3.y, quad->p4.y)));
3249 min_x = MIN (quad->p1.x, MIN (quad->p2.x, MIN (quad->p3.x, quad->p4.x)));
3250 min_y = MIN (quad->p1.y, MIN (quad->p2.y, MIN (quad->p3.y, quad->p4.y)));
3252 if (min_x < bbox->x1)
3254 if (min_y < bbox->y1)
3256 if (max_x > bbox->x2)
3258 if (max_y > bbox->y2)
3261 g_list_free (rects);
3263 if (n_rects == 0 && bbox) {
3278 PopplerAnnot *poppler_annot;
3281 PopplerPage *poppler_page;
3285 PopplerRectangle poppler_rect;
3287 PopplerColor poppler_color;
3297 poppler_page_get_size (poppler_page, NULL, &height);
3298 poppler_rect.x1 = rect.
x1;
3299 poppler_rect.x2 = rect.
x2;
3300 poppler_rect.y1 = height - rect.
y2;
3301 poppler_rect.y2 = height - rect.
y1;
3308 poppler_annot = poppler_annot_text_new (pdf_document->
document, &poppler_rect);
3311 poppler_annot_text_set_icon (POPPLER_ANNOT_TEXT (poppler_annot),
3322 poppler_annot = poppler_annot_text_markup_new_highlight (pdf_document->
document, &poppler_rect, quads);
3325 g_assert_not_reached ();
3327 g_array_unref (quads);
3331 g_assert_not_reached ();
3335 poppler_color.red = color.red;
3336 poppler_color.green = color.green;
3337 poppler_color.blue = color.blue;
3338 poppler_annot_set_color (poppler_annot, &poppler_color);
3348 poppler_rect.x1 = popup_rect.
x1;
3349 poppler_rect.x2 = popup_rect.
x2;
3350 poppler_rect.y1 = height - popup_rect.
y2;
3351 poppler_rect.y2 = height - popup_rect.
y1;
3352 poppler_annot_markup_set_popup (POPPLER_ANNOT_MARKUP (poppler_annot), &poppler_rect);
3353 poppler_annot_markup_set_popup_is_open (POPPLER_ANNOT_MARKUP (poppler_annot),
3359 poppler_annot_markup_set_label (POPPLER_ANNOT_MARKUP (poppler_annot), label);
3362 poppler_page_add_annot (poppler_page, poppler_annot);
3365 annot_mapping->
area = rect;
3366 annot_mapping->
data = annot;
3367 g_signal_connect (annot,
"notify::area",
3370 g_object_set_data_full (G_OBJECT (annot),
3373 (GDestroyNotify) g_object_unref);
3375 if (pdf_document->
annots) {
3377 GINT_TO_POINTER (page->
index));
3379 pdf_document->
annots = g_hash_table_new_full (g_direct_hash,
3381 (GDestroyNotify)NULL,
3383 mapping_list = NULL;
3390 list = g_list_append (list, annot_mapping);
3392 list = g_list_append (list, annot_mapping);
3394 g_hash_table_insert (pdf_document->
annots,
3395 GINT_TO_POINTER (page->
index),
3405 PopplerAnnot* dst_annot)
3408 PopplerColor *color;
3410 contents = poppler_annot_get_contents (src_annot);
3411 poppler_annot_set_contents (dst_annot, contents);
3414 poppler_annot_set_flags (dst_annot, poppler_annot_get_flags (src_annot));
3416 color = poppler_annot_get_color (src_annot);
3417 poppler_annot_set_color (dst_annot, color);
3420 if (POPPLER_IS_ANNOT_MARKUP (src_annot) && POPPLER_IS_ANNOT_MARKUP (dst_annot)) {
3421 PopplerAnnotMarkup *src_markup = POPPLER_ANNOT_MARKUP (src_annot);
3422 PopplerAnnotMarkup *dst_markup = POPPLER_ANNOT_MARKUP (dst_annot);
3425 label = poppler_annot_markup_get_label (src_markup);
3426 poppler_annot_markup_set_label (dst_markup, label);
3429 poppler_annot_markup_set_opacity (dst_markup, poppler_annot_markup_get_opacity (src_markup));
3431 if (poppler_annot_markup_has_popup (src_markup)) {
3432 PopplerRectangle popup_rect;
3434 if (poppler_annot_markup_get_popup_rectangle (src_markup, &popup_rect)) {
3435 poppler_annot_markup_set_popup (dst_markup, &popup_rect);
3436 poppler_annot_markup_set_popup_is_open (dst_markup, poppler_annot_markup_get_popup_is_open (src_markup));
3448 PopplerAnnot *poppler_annot;
3450 poppler_annot = POPPLER_ANNOT (g_object_get_data (G_OBJECT (annot),
"poppler-annot"));
3455 poppler_annot_set_contents (poppler_annot,
3463 color.red = ev_color.red;
3464 color.green = ev_color.green;
3465 color.blue = ev_color.blue;
3466 poppler_annot_set_color (poppler_annot, &color);
3471 PopplerRectangle poppler_rect;
3476 poppler_page_get_size (POPPLER_PAGE (page->
backend_page), NULL, &height);
3479 poppler_rect.x1 = area.
x1;
3480 poppler_rect.x2 = area.
x2;
3481 poppler_rect.y1 = height - area.
y2;
3482 poppler_rect.y2 = height - area.
y1;
3483 poppler_annot_set_rectangle (poppler_annot, &poppler_rect);
3488 PopplerAnnotMarkup *markup = POPPLER_ANNOT_MARKUP (poppler_annot);
3497 PopplerRectangle poppler_rect;
3501 poppler_page_get_size (POPPLER_PAGE (page->
backend_page),
3505 poppler_rect.x1 = ev_rect.
x1;
3506 poppler_rect.x2 = ev_rect.
x2;
3507 poppler_rect.y1 = height - ev_rect.
y2;
3508 poppler_rect.y2 = height - ev_rect.
y1;
3510 if (poppler_annot_markup_has_popup (markup))
3511 poppler_annot_markup_set_popup_rectangle (markup, &poppler_rect);
3513 poppler_annot_markup_set_popup (markup, &poppler_rect);
3521 PopplerAnnotText *text = POPPLER_ANNOT_TEXT (poppler_annot);
3524 poppler_annot_text_set_is_open (text,
3537 PopplerAnnotTextMarkup *text_markup = POPPLER_ANNOT_TEXT_MARKUP (poppler_annot);
3542 PopplerRectangle rect;
3543 PopplerAnnot *new_annot = NULL;
3546 PopplerPage *poppler_page;
3550 quads = poppler_annot_text_markup_get_quadrilaterals (text_markup);
3551 poppler_annot_get_rectangle (POPPLER_ANNOT (text_markup), &rect);
3555 new_annot = poppler_annot_text_markup_new_highlight (pdf_document->
document, &rect, quads);
3558 new_annot = poppler_annot_text_markup_new_strikeout (pdf_document->
document, &rect, quads);
3561 new_annot = poppler_annot_text_markup_new_underline (pdf_document->
document, &rect, quads);
3564 new_annot = poppler_annot_text_markup_new_squiggly (pdf_document->
document, &rect, quads);
3568 g_array_unref (quads);
3575 poppler_page_remove_annot (poppler_page, poppler_annot);
3576 poppler_page_add_annot (poppler_page, new_annot);
3577 g_object_set_data_full (G_OBJECT (annot),
3580 (GDestroyNotify) g_object_unref);
3586 PopplerRectangle bbox;
3588 PopplerPage *poppler_page;
3595 poppler_annot_text_markup_set_quadrilaterals (text_markup, quads);
3596 poppler_annot_set_rectangle (poppler_annot, &bbox);
3597 g_array_unref (quads);
3599 if (bbox.x1 != 0 && bbox.y1 != 0 && bbox.x2 != 0 && bbox.y2 != 0) {
3602 poppler_page_get_size (poppler_page, NULL, &height);
3605 area.
y1 = height - bbox.y2;
3606 area.
y2 = height - bbox.y1;
3637 if (g_path_is_absolute (filename)) {
3638 file = g_file_new_for_path (filename);
3639 }
else if (g_strrstr (filename,
"://")) {
3640 file = g_file_new_for_uri (filename);
3647 base_dir = g_path_get_dirname (doc_path);
3650 path = g_build_filename (base_dir, filename, NULL);
3653 file = g_file_new_for_path (path);
3663 PopplerMovie *movie)
3669 file =
get_media_file (poppler_movie_get_filename (movie), document);
3670 uri = g_file_get_uri (file);
3671 g_object_unref (file);
3683 g_file_delete (file, NULL, NULL);
3684 g_object_unref (file);
3693 gint fd = GPOINTER_TO_INT (data);
3695 return write (fd, buffer, count) == (gssize)count;
3701 PopplerMedia *poppler_media)
3706 gboolean is_temp_file =
FALSE;
3711 if (poppler_media_is_embedded (poppler_media)) {
3715 fd =
ev_mkstemp (
"evmedia.XXXXXX", &filename, NULL);
3719 if (poppler_media_save_to_callback (poppler_media,
3721 GINT_TO_POINTER (fd), NULL)) {
3722 file = g_file_new_for_path (filename);
3723 is_temp_file =
TRUE;
3728 file =
get_media_file (poppler_media_get_filename (poppler_media), document);
3734 uri = g_file_get_uri (file);
3740 g_object_set_data_full (G_OBJECT (media),
"poppler-media-temp-file", file, (GDestroyNotify)
delete_temp_file);
3742 g_object_unref (file);
3751 GList *retval = NULL;
3753 PopplerPage *poppler_page;
3763 annots = poppler_page_get_annot_mapping (poppler_page);
3764 poppler_page_get_size (poppler_page, NULL, &height);
3766 for (list = annots; list; list = list->next) {
3767 PopplerAnnotMapping *mapping;
3771 mapping = (PopplerAnnotMapping *)list->
data;
3773 switch (poppler_annot_get_annot_type (mapping->annot)) {
3774 case POPPLER_ANNOT_MOVIE: {
3775 PopplerAnnotMovie *poppler_annot;
3777 poppler_annot = POPPLER_ANNOT_MOVIE (mapping->annot);
3779 poppler_annot_movie_get_movie (poppler_annot));
3782 case POPPLER_ANNOT_SCREEN: {
3783 PopplerAction *action;
3785 action = poppler_annot_screen_get_action (POPPLER_ANNOT_SCREEN (mapping->annot));
3786 if (action && action->type == POPPLER_ACTION_RENDITION) {
3788 action->rendition.media);
3801 media_mapping->
data = media;
3802 media_mapping->
area.
x1 = mapping->area.x1;
3803 media_mapping->
area.
x2 = mapping->area.x2;
3804 media_mapping->
area.
y1 = height - mapping->area.y2;
3805 media_mapping->
area.
y2 = height - mapping->area.y1;
3807 retval = g_list_prepend (retval, media_mapping);
3810 poppler_page_free_annot_mapping (annots);
3840 if (sdata->
len + count > sdata->
max) {
3841 new_max = MAX (sdata->
max * 2, sdata->
len + count);
3842 new_buffer = (gchar *)g_realloc (sdata->
buffer, new_max);
3844 sdata->
buffer = new_buffer;
3845 sdata->
max = new_max;
3849 sdata->
len += count;
3860 static const gint initial_max = 1024;
3866 sdata.
buffer = (gchar *) g_malloc (initial_max);
3867 sdata.
max = initial_max;
3870 if (! poppler_attachment_save_to_callback (attachment,
3879 *buffer_size = sdata.
len;
3890 GList *retval = NULL;
3892 attachments = poppler_document_get_attachments (pdf_document->
document);
3894 for (list = attachments; list; list = list->next) {
3895 PopplerAttachment *attachment;
3899 GError *error = NULL;
3901 attachment = (PopplerAttachment *) list->data;
3905 attachment->description,
3910 retval = g_list_prepend (retval, ev_attachment);
3913 g_warning (
"%s", error->message);
3914 g_error_free (error);
3920 g_object_unref (attachment);
3923 return g_list_reverse (retval);
3931 return poppler_document_has_attachments (pdf_document->
document);
3946 PopplerLayersIter *iter;
3948 iter = poppler_layers_iter_new (pdf_document->
document);
3951 poppler_layers_iter_free (iter);
3958 GtkTreeModel *model,
3959 GtkTreeIter *parent,
3960 PopplerLayersIter *iter)
3963 GtkTreeIter tree_iter;
3964 PopplerLayersIter *child;
3965 PopplerLayer *layer;
3971 layer = poppler_layers_iter_get_layer (iter);
3973 markup = g_markup_escape_text (poppler_layer_get_title (layer), -1);
3974 visible = poppler_layer_is_visible (layer);
3975 rb_group = poppler_layer_get_radio_button_group_id (layer);
3976 ev_layer =
ev_layer_new (poppler_layer_is_parent (layer),
3978 g_object_set_data_full (G_OBJECT (ev_layer),
3980 g_object_ref (layer),
3981 (GDestroyNotify) g_object_unref);
3985 title = poppler_layers_iter_get_title (iter);
3986 markup = g_markup_escape_text (title, -1);
3993 gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
3994 gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
4003 g_object_unref (ev_layer);
4006 child = poppler_layers_iter_get_child (iter);
4009 poppler_layers_iter_free (child);
4010 }
while (poppler_layers_iter_next (iter));
4013 static GtkTreeModel *
4016 GtkTreeModel *model = NULL;
4018 PopplerLayersIter *iter;
4020 iter = poppler_layers_iter_new (pdf_document->
document);
4030 poppler_layers_iter_free (iter);
4039 PopplerLayer *poppler_layer;
4041 poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer),
"poppler-layer"));
4042 poppler_layer_show (poppler_layer);
4049 PopplerLayer *poppler_layer;
4051 poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer),
"poppler-layer"));
4052 poppler_layer_hide (poppler_layer);
4059 PopplerLayer *poppler_layer;
4061 poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer),
"poppler-layer"));
4062 return poppler_layer_is_visible (poppler_layer);