1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* pdfdocument.h: Implementation of EvDocument for PDF
3 * Copyright (C) 2004, Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <poppler-document.h>
27 #include <poppler-page.h>
29 #include <cairo-pdf.h>
31 #include <glib/gi18n.h>
33 #include "ev-poppler.h"
34 #include "ev-file-exporter.h"
35 #include "ev-document-find.h"
36 #include "ev-document-misc.h"
37 #include "ev-document-links.h"
38 #include "ev-document-images.h"
39 #include "ev-document-fonts.h"
40 #include "ev-document-security.h"
41 #include "ev-document-thumbnails.h"
42 #include "ev-document-transition.h"
43 #include "ev-selection.h"
44 #include "ev-attachment.h"
48 PdfDocument *document;
57 EvFileExporterFormat format;
58 PopplerPSFile *ps_file;
64 struct _PdfDocumentClass
66 GObjectClass parent_class;
71 GObject parent_instance;
73 PopplerDocument *document;
76 PopplerFontInfo *font_info;
77 PopplerFontsIter *fonts_iter;
78 int fonts_scanned_pages;
80 PdfDocumentSearch *search;
81 PdfPrintContext *print_ctx;
84 static void pdf_document_document_iface_init (EvDocumentIface *iface);
85 static void pdf_document_security_iface_init (EvDocumentSecurityIface *iface);
86 static void pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
87 static void pdf_document_document_links_iface_init (EvDocumentLinksIface *iface);
88 static void pdf_document_document_images_iface_init (EvDocumentImagesIface *iface);
89 static void pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface);
90 static void pdf_document_find_iface_init (EvDocumentFindIface *iface);
91 static void pdf_document_file_exporter_iface_init (EvFileExporterIface *iface);
92 static void pdf_selection_iface_init (EvSelectionIface *iface);
93 static void pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface);
94 static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
98 static int pdf_document_get_n_pages (EvDocument *document);
100 static EvLinkDest *ev_link_dest_from_dest (PdfDocument *pdf_document,
102 static EvLink *ev_link_from_action (PdfDocument *pdf_document,
103 PopplerAction *action);
104 static void pdf_document_search_free (PdfDocumentSearch *search);
105 static void pdf_print_context_free (PdfPrintContext *ctx);
108 G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT,
110 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,
111 pdf_document_document_iface_init);
112 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_SECURITY,
113 pdf_document_security_iface_init);
114 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
115 pdf_document_document_thumbnails_iface_init);
116 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS,
117 pdf_document_document_links_iface_init);
118 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_IMAGES,
119 pdf_document_document_images_iface_init);
120 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FONTS,
121 pdf_document_document_fonts_iface_init);
122 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND,
123 pdf_document_find_iface_init);
124 G_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER,
125 pdf_document_file_exporter_iface_init);
126 G_IMPLEMENT_INTERFACE (EV_TYPE_SELECTION,
127 pdf_selection_iface_init);
128 G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_TRANSITION,
129 pdf_document_page_transition_iface_init);
134 set_rc_data (PdfDocument *pdf_document,
137 if (rc->data == NULL) {
138 rc->data = poppler_document_get_page (pdf_document->document,
140 rc->destroy = g_object_unref;
142 g_assert (rc->page == poppler_page_get_index (POPPLER_PAGE (rc->data)));
147 pdf_document_search_free (PdfDocumentSearch *search)
149 PdfDocument *pdf_document = search->document;
153 if (search->idle != 0)
154 g_source_remove (search->idle);
156 n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
157 for (i = 0; i < n_pages; i++) {
158 g_list_foreach (search->pages[i], (GFunc) g_free, NULL);
159 g_list_free (search->pages[i]);
161 g_free (search->pages);
163 g_free (search->text);
168 pdf_document_dispose (GObject *object)
170 PdfDocument *pdf_document = PDF_DOCUMENT(object);
172 if (pdf_document->print_ctx) {
173 pdf_print_context_free (pdf_document->print_ctx);
174 pdf_document->print_ctx = NULL;
177 if (pdf_document->search) {
178 pdf_document_search_free (pdf_document->search);
179 pdf_document->search = NULL;
182 if (pdf_document->document) {
183 g_object_unref (pdf_document->document);
186 if (pdf_document->font_info) {
187 poppler_font_info_free (pdf_document->font_info);
190 if (pdf_document->fonts_iter) {
191 poppler_fonts_iter_free (pdf_document->fonts_iter);
194 G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object);
198 pdf_document_class_init (PdfDocumentClass *klass)
200 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
202 g_object_class->dispose = pdf_document_dispose;
206 pdf_document_init (PdfDocument *pdf_document)
208 pdf_document->password = NULL;
212 convert_error (GError *poppler_error,
215 if (poppler_error == NULL)
218 if (poppler_error->domain == POPPLER_ERROR) {
219 /* convert poppler errors into EvDocument errors */
220 gint code = EV_DOCUMENT_ERROR_INVALID;
221 if (poppler_error->code == POPPLER_ERROR_INVALID)
222 code = EV_DOCUMENT_ERROR_INVALID;
223 else if (poppler_error->code == POPPLER_ERROR_ENCRYPTED)
224 code = EV_DOCUMENT_ERROR_ENCRYPTED;
230 poppler_error->message,
233 g_propagate_error (error, poppler_error);
240 pdf_document_save (EvDocument *document,
245 GError *poppler_error = NULL;
247 retval = poppler_document_save (PDF_DOCUMENT (document)->document,
251 convert_error (poppler_error, error);
257 pdf_document_load (EvDocument *document,
261 GError *poppler_error = NULL;
262 PdfDocument *pdf_document = PDF_DOCUMENT (document);
264 pdf_document->document =
265 poppler_document_new_from_file (uri, pdf_document->password, &poppler_error);
267 if (pdf_document->document == NULL) {
268 convert_error (poppler_error, error);
276 pdf_document_get_n_pages (EvDocument *document)
278 return poppler_document_get_n_pages (PDF_DOCUMENT (document)->document);
282 pdf_document_get_page_size (EvDocument *document,
287 PdfDocument *pdf_document = PDF_DOCUMENT (document);
288 PopplerPage *poppler_page;
290 poppler_page = poppler_document_get_page (pdf_document->document, page);
291 poppler_page_get_size (poppler_page, width, height);
292 g_object_unref (poppler_page);
296 pdf_document_get_page_label (EvDocument *document,
299 PopplerPage *poppler_page;
302 poppler_page = poppler_document_get_page (PDF_DOCUMENT (document)->document,
305 g_object_get (G_OBJECT (poppler_page),
308 g_object_unref (poppler_page);
314 pdf_document_has_attachments (EvDocument *document)
316 PdfDocument *pdf_document;
318 pdf_document = PDF_DOCUMENT (document);
320 return poppler_document_has_attachments (pdf_document->document);
323 struct SaveToBufferData {
329 attachment_save_to_buffer_callback (const gchar *buf,
334 struct SaveToBufferData *sdata = (SaveToBufferData *)user_data;
338 if (sdata->len + count > sdata->max) {
339 new_max = MAX (sdata->max * 2, sdata->len + count);
340 new_buffer = (gchar *)g_realloc (sdata->buffer, new_max);
342 sdata->buffer = new_buffer;
343 sdata->max = new_max;
346 memcpy (sdata->buffer + sdata->len, buf, count);
353 attachment_save_to_buffer (PopplerAttachment *attachment,
358 static const gint initial_max = 1024;
359 struct SaveToBufferData sdata;
364 sdata.buffer = (gchar *) g_malloc (initial_max);
365 sdata.max = initial_max;
368 if (! poppler_attachment_save_to_callback (attachment,
369 attachment_save_to_buffer_callback,
372 g_free (sdata.buffer);
376 *buffer = sdata.buffer;
377 *buffer_size = sdata.len;
383 pdf_document_get_attachments (EvDocument *document)
385 PdfDocument *pdf_document;
388 GList *retval = NULL;
390 pdf_document = PDF_DOCUMENT (document);
392 if (!pdf_document_has_attachments (document))
395 attachments = poppler_document_get_attachments (pdf_document->document);
397 for (list = attachments; list; list = list->next) {
398 PopplerAttachment *attachment;
399 EvAttachment *ev_attachment;
402 GError *error = NULL;
404 attachment = (PopplerAttachment *) list->data;
406 if (attachment_save_to_buffer (attachment, &data, &size, &error)) {
407 ev_attachment = ev_attachment_new (attachment->name,
408 attachment->description,
413 retval = g_list_prepend (retval, ev_attachment);
416 g_warning ("%s", error->message);
417 g_error_free (error);
423 g_object_unref (attachment);
426 return g_list_reverse (retval);
429 static cairo_surface_t *
430 pdf_document_render (EvDocument *document,
433 PdfDocument *pdf_document;
434 cairo_surface_t *surface;
435 double width_points, height_points;
438 pdf_document = PDF_DOCUMENT (document);
440 set_rc_data (pdf_document, rc);
442 poppler_page_get_size (POPPLER_PAGE (rc->data), &width_points, &height_points);
444 if (rc->rotation == 90 || rc->rotation == 270) {
445 width = (int) ((height_points * rc->scale) + 0.5);
446 height = (int) ((width_points * rc->scale) + 0.5);
448 width = (int) ((width_points * rc->scale) + 0.5);
449 height = (int) ((height_points * rc->scale) + 0.5);
452 #ifdef HAVE_POPPLER_PAGE_RENDER
455 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
457 memset (cairo_image_surface_get_data (surface), 0xff,
458 cairo_image_surface_get_height (surface) *
459 cairo_image_surface_get_stride (surface));
461 cr = cairo_create (surface);
462 switch (rc->rotation) {
464 cairo_translate (cr, width, 0);
467 cairo_translate (cr, width, height);
470 cairo_translate (cr, 0, height);
473 cairo_translate (cr, 0, 0);
475 cairo_scale (cr, rc->scale, rc->scale);
476 cairo_rotate (cr, rc->rotation * G_PI / 180.0);
477 poppler_page_render (POPPLER_PAGE (rc->data), cr);
479 #else /* HAVE_POPPLER_PAGE_RENDER */
482 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
486 poppler_page_render_to_pixbuf (POPPLER_PAGE (rc->data),
492 surface = ev_document_misc_surface_from_pixbuf (pixbuf);
493 g_object_unref (pixbuf);
494 #endif /* HAVE_POPPLER_PAGE_RENDER */
499 /* EvDocumentSecurity */
502 pdf_document_has_document_security (EvDocumentSecurity *document_security)
504 /* FIXME: do we really need to have this? */
509 pdf_document_set_password (EvDocumentSecurity *document_security,
510 const char *password)
512 PdfDocument *document = PDF_DOCUMENT (document_security);
514 if (document->password)
515 g_free (document->password);
517 document->password = g_strdup (password);
521 pdf_document_can_get_text (EvDocument *document)
526 static EvDocumentInfo *
527 pdf_document_get_info (EvDocument *document)
529 EvDocumentInfo *info;
530 PopplerPageLayout layout;
531 PopplerPageMode mode;
532 PopplerViewerPreferences view_prefs;
533 PopplerPermissions permissions;
535 info = g_new0 (EvDocumentInfo, 1);
537 info->fields_mask = EV_DOCUMENT_INFO_TITLE |
538 EV_DOCUMENT_INFO_FORMAT |
539 EV_DOCUMENT_INFO_AUTHOR |
540 EV_DOCUMENT_INFO_SUBJECT |
541 EV_DOCUMENT_INFO_KEYWORDS |
542 EV_DOCUMENT_INFO_LAYOUT |
543 EV_DOCUMENT_INFO_START_MODE |
544 EV_DOCUMENT_INFO_PERMISSIONS |
545 EV_DOCUMENT_INFO_UI_HINTS |
546 EV_DOCUMENT_INFO_CREATOR |
547 EV_DOCUMENT_INFO_PRODUCER |
548 EV_DOCUMENT_INFO_CREATION_DATE |
549 EV_DOCUMENT_INFO_MOD_DATE |
550 EV_DOCUMENT_INFO_LINEARIZED |
551 EV_DOCUMENT_INFO_N_PAGES |
552 EV_DOCUMENT_INFO_SECURITY |
553 EV_DOCUMENT_INFO_PAPER_SIZE;
555 g_object_get (PDF_DOCUMENT (document)->document,
556 "title", &(info->title),
557 "format", &(info->format),
558 "author", &(info->author),
559 "subject", &(info->subject),
560 "keywords", &(info->keywords),
562 "page-layout", &layout,
563 "viewer-preferences", &view_prefs,
564 "permissions", &permissions,
565 "creator", &(info->creator),
566 "producer", &(info->producer),
567 "creation-date", &(info->creation_date),
568 "mod-date", &(info->modified_date),
569 "linearized", &(info->linearized),
572 pdf_document_get_page_size(document, 0,
573 &(info->paper_width),
574 &(info->paper_height));
577 info->paper_width = info->paper_width / 72.0f * 25.4f;
578 info->paper_height = info->paper_height / 72.0f * 25.4f;
581 case POPPLER_PAGE_LAYOUT_SINGLE_PAGE:
582 info->layout = EV_DOCUMENT_LAYOUT_SINGLE_PAGE;
584 case POPPLER_PAGE_LAYOUT_ONE_COLUMN:
585 info->layout = EV_DOCUMENT_LAYOUT_ONE_COLUMN;
587 case POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT:
588 info->layout = EV_DOCUMENT_LAYOUT_TWO_COLUMN_LEFT;
590 case POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT:
591 info->layout = EV_DOCUMENT_LAYOUT_TWO_COLUMN_RIGHT;
592 case POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT:
593 info->layout = EV_DOCUMENT_LAYOUT_TWO_PAGE_LEFT;
595 case POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT:
596 info->layout = EV_DOCUMENT_LAYOUT_TWO_PAGE_RIGHT;
603 case POPPLER_PAGE_MODE_NONE:
604 info->mode = EV_DOCUMENT_MODE_NONE;
606 case POPPLER_PAGE_MODE_USE_THUMBS:
607 info->mode = EV_DOCUMENT_MODE_USE_THUMBS;
609 case POPPLER_PAGE_MODE_USE_OC:
610 info->mode = EV_DOCUMENT_MODE_USE_OC;
612 case POPPLER_PAGE_MODE_FULL_SCREEN:
613 info->mode = EV_DOCUMENT_MODE_FULL_SCREEN;
615 case POPPLER_PAGE_MODE_USE_ATTACHMENTS:
616 info->mode = EV_DOCUMENT_MODE_USE_ATTACHMENTS;
622 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR) {
623 info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_TOOLBAR;
625 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR) {
626 info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_MENUBAR;
628 if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI) {
629 info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_WINDOWUI;
631 if (view_prefs & POPPLER_VIEWER_PREFERENCES_FIT_WINDOW) {
632 info->ui_hints |= EV_DOCUMENT_UI_HINT_FIT_WINDOW;
634 if (view_prefs & POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW) {
635 info->ui_hints |= EV_DOCUMENT_UI_HINT_CENTER_WINDOW;
637 if (view_prefs & POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE) {
638 info->ui_hints |= EV_DOCUMENT_UI_HINT_DISPLAY_DOC_TITLE;
640 if (view_prefs & POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL) {
641 info->ui_hints |= EV_DOCUMENT_UI_HINT_DIRECTION_RTL;
644 info->permissions = 0;
645 if (permissions & POPPLER_PERMISSIONS_OK_TO_PRINT) {
646 info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT;
648 if (permissions & POPPLER_PERMISSIONS_OK_TO_MODIFY) {
649 info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY;
651 if (permissions & POPPLER_PERMISSIONS_OK_TO_COPY) {
652 info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_COPY;
654 if (permissions & POPPLER_PERMISSIONS_OK_TO_ADD_NOTES) {
655 info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES;
658 info->n_pages = ev_document_get_n_pages (document);
660 if (ev_document_security_has_document_security (EV_DOCUMENT_SECURITY (document))) {
661 /* translators: this is the document security state */
662 info->security = g_strdup (_("Yes"));
664 /* translators: this is the document security state */
665 info->security = g_strdup (_("No"));
672 pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect)
674 PdfDocument *pdf_document = PDF_DOCUMENT (document);
675 PopplerPage *poppler_page;
680 poppler_page = poppler_document_get_page (pdf_document->document, page);
681 g_return_val_if_fail (poppler_page != NULL, NULL);
683 poppler_page_get_size (poppler_page, NULL, &height);
685 r.y1 = height - rect->y2;
687 r.y2 = height - rect->y1;
689 text = poppler_page_get_text (poppler_page, &r);
691 g_object_unref (poppler_page);
697 pdf_document_document_iface_init (EvDocumentIface *iface)
699 iface->save = pdf_document_save;
700 iface->load = pdf_document_load;
701 iface->get_n_pages = pdf_document_get_n_pages;
702 iface->get_page_size = pdf_document_get_page_size;
703 iface->get_page_label = pdf_document_get_page_label;
704 iface->has_attachments = pdf_document_has_attachments;
705 iface->get_attachments = pdf_document_get_attachments;
706 iface->render = pdf_document_render;
707 iface->get_text = pdf_document_get_text;
708 iface->can_get_text = pdf_document_can_get_text;
709 iface->get_info = pdf_document_get_info;
713 pdf_document_security_iface_init (EvDocumentSecurityIface *iface)
715 iface->has_document_security = pdf_document_has_document_security;
716 iface->set_password = pdf_document_set_password;
720 pdf_document_fonts_get_progress (EvDocumentFonts *document_fonts)
722 PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
725 n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
727 return (double)pdf_document->fonts_scanned_pages / (double)n_pages;
731 pdf_document_fonts_scan (EvDocumentFonts *document_fonts,
734 PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
737 g_return_val_if_fail (PDF_IS_DOCUMENT (document_fonts), FALSE);
739 if (pdf_document->font_info == NULL) {
740 pdf_document->font_info = poppler_font_info_new (pdf_document->document);
743 if (pdf_document->fonts_iter) {
744 poppler_fonts_iter_free (pdf_document->fonts_iter);
747 pdf_document->fonts_scanned_pages += n_pages;
749 result = poppler_font_info_scan (pdf_document->font_info, n_pages,
750 &pdf_document->fonts_iter);
752 pdf_document->fonts_scanned_pages = 0;
753 poppler_font_info_free (pdf_document->font_info);
754 pdf_document->font_info = NULL;
761 font_type_to_string (PopplerFontType type)
764 case POPPLER_FONT_TYPE_TYPE1:
766 case POPPLER_FONT_TYPE_TYPE1C:
768 case POPPLER_FONT_TYPE_TYPE3:
770 case POPPLER_FONT_TYPE_TRUETYPE:
771 return _("TrueType");
772 case POPPLER_FONT_TYPE_CID_TYPE0:
773 return _("Type 1 (CID)");
774 case POPPLER_FONT_TYPE_CID_TYPE0C:
775 return _("Type 1C (CID)");
776 case POPPLER_FONT_TYPE_CID_TYPE2:
777 return _("TrueType (CID)");
779 return _("Unknown font type");
784 pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
787 PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
788 PopplerFontsIter *iter = pdf_document->fonts_iter;
790 g_return_if_fail (PDF_IS_DOCUMENT (document_fonts));
796 GtkTreeIter list_iter;
799 const char *embedded;
802 name = poppler_fonts_iter_get_name (iter);
808 type = font_type_to_string (
809 poppler_fonts_iter_get_font_type (iter));
811 if (poppler_fonts_iter_is_embedded (iter)) {
812 if (poppler_fonts_iter_is_subset (iter))
813 embedded = _("Embedded subset");
815 embedded = _("Embedded");
817 embedded = _("Not embedded");
820 details = g_markup_printf_escaped ("%s\n%s", type, embedded);
822 gtk_list_store_append (GTK_LIST_STORE (model), &list_iter);
823 gtk_list_store_set (GTK_LIST_STORE (model), &list_iter,
824 EV_DOCUMENT_FONTS_COLUMN_NAME, name,
825 EV_DOCUMENT_FONTS_COLUMN_DETAILS, details,
829 } while (poppler_fonts_iter_next (iter));
833 pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface)
835 iface->fill_model = pdf_document_fonts_fill_model;
836 iface->scan = pdf_document_fonts_scan;
837 iface->get_progress = pdf_document_fonts_get_progress;
841 pdf_document_links_has_document_links (EvDocumentLinks *document_links)
843 PdfDocument *pdf_document = PDF_DOCUMENT (document_links);
844 PopplerIndexIter *iter;
846 g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), FALSE);
848 iter = poppler_index_iter_new (pdf_document->document);
851 poppler_index_iter_free (iter);
857 ev_link_dest_from_dest (PdfDocument *pdf_document,
860 EvLinkDest *ev_dest = NULL;
861 const char *unimplemented_dest = NULL;
863 g_assert (dest != NULL);
865 switch (dest->type) {
866 case POPPLER_DEST_XYZ: {
867 PopplerPage *poppler_page;
870 poppler_page = poppler_document_get_page (pdf_document->document,
871 MAX (0, dest->page_num - 1));
872 poppler_page_get_size (poppler_page, NULL, &height);
873 ev_dest = ev_link_dest_new_xyz (dest->page_num - 1,
877 g_object_unref (poppler_page);
880 case POPPLER_DEST_FIT:
881 ev_dest = ev_link_dest_new_fit (dest->page_num - 1);
883 case POPPLER_DEST_FITH: {
884 PopplerPage *poppler_page;
887 poppler_page = poppler_document_get_page (pdf_document->document,
888 MAX (0, dest->page_num - 1));
889 poppler_page_get_size (poppler_page, NULL, &height);
890 ev_dest = ev_link_dest_new_fith (dest->page_num - 1,
892 g_object_unref (poppler_page);
895 case POPPLER_DEST_FITV:
896 ev_dest = ev_link_dest_new_fitv (dest->page_num - 1,
899 case POPPLER_DEST_FITR: {
900 PopplerPage *poppler_page;
903 poppler_page = poppler_document_get_page (pdf_document->document,
904 MAX (0, dest->page_num - 1));
905 poppler_page_get_size (poppler_page, NULL, &height);
906 ev_dest = ev_link_dest_new_fitr (dest->page_num - 1,
908 height - dest->bottom,
911 g_object_unref (poppler_page);
914 case POPPLER_DEST_FITB:
915 unimplemented_dest = "POPPLER_DEST_FITB";
917 case POPPLER_DEST_FITBH:
918 unimplemented_dest = "POPPLER_DEST_FITBH";
920 case POPPLER_DEST_FITBV:
921 unimplemented_dest = "POPPLER_DEST_FITBV";
923 case POPPLER_DEST_NAMED:
924 ev_dest = ev_link_dest_new_named (dest->named_dest);
926 case POPPLER_DEST_UNKNOWN:
927 unimplemented_dest = "POPPLER_DEST_UNKNOWN";
931 if (unimplemented_dest) {
932 g_warning ("Unimplemented named action: %s, please post a "
933 "bug report in Evince bugzilla "
934 "(http://bugzilla.gnome.org) with a testcase.",
939 ev_dest = ev_link_dest_new_page (dest->page_num - 1);
945 ev_link_from_action (PdfDocument *pdf_document,
946 PopplerAction *action)
949 EvLinkAction *ev_action = NULL;
950 const char *unimplemented_action = NULL;
952 switch (action->type) {
953 case POPPLER_ACTION_GOTO_DEST: {
956 dest = ev_link_dest_from_dest (pdf_document, action->goto_dest.dest);
957 ev_action = ev_link_action_new_dest (dest);
960 case POPPLER_ACTION_GOTO_REMOTE: {
963 dest = ev_link_dest_from_dest (pdf_document, action->goto_remote.dest);
964 ev_action = ev_link_action_new_remote (dest,
965 action->goto_remote.file_name);
969 case POPPLER_ACTION_LAUNCH:
970 ev_action = ev_link_action_new_launch (action->launch.file_name,
971 action->launch.params);
973 case POPPLER_ACTION_URI:
974 ev_action = ev_link_action_new_external_uri (action->uri.uri);
976 case POPPLER_ACTION_NAMED:
977 ev_action = ev_link_action_new_named (action->named.named_dest);
979 case POPPLER_ACTION_MOVIE:
980 unimplemented_action = "POPPLER_ACTION_MOVIE";
982 case POPPLER_ACTION_UNKNOWN:
983 unimplemented_action = "POPPLER_ACTION_UNKNOWN";
986 if (unimplemented_action) {
987 g_warning ("Unimplemented action: %s, please post a bug report with a testcase.",
988 unimplemented_action);
991 link = ev_link_new (action->any.title, ev_action);
997 build_tree (PdfDocument *pdf_document,
1000 PopplerIndexIter *iter)
1004 GtkTreeIter tree_iter;
1005 PopplerIndexIter *child;
1006 PopplerAction *action;
1007 EvLink *link = NULL;
1011 action = poppler_index_iter_get_action (iter);
1012 expand = poppler_index_iter_is_open (iter);
1017 switch (action->type) {
1018 case POPPLER_ACTION_GOTO_DEST: {
1019 /* For bookmarks, solve named destinations */
1020 if (action->goto_dest.dest->type == POPPLER_DEST_NAMED) {
1022 EvLinkDest *ev_dest = NULL;
1023 EvLinkAction *ev_action;
1025 dest = poppler_document_find_dest (pdf_document->document,
1026 action->goto_dest.dest->named_dest);
1028 link = ev_link_from_action (pdf_document, action);
1032 ev_dest = ev_link_dest_from_dest (pdf_document, dest);
1033 poppler_dest_free (dest);
1035 ev_action = ev_link_action_new_dest (ev_dest);
1036 link = ev_link_new (action->any.title, ev_action);
1038 link = ev_link_from_action (pdf_document, action);
1043 link = ev_link_from_action (pdf_document, action);
1048 poppler_action_free (action);
1052 gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
1053 title_markup = g_markup_escape_text (ev_link_get_title (link), -1);
1055 gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
1056 EV_DOCUMENT_LINKS_COLUMN_MARKUP, title_markup,
1057 EV_DOCUMENT_LINKS_COLUMN_LINK, link,
1058 EV_DOCUMENT_LINKS_COLUMN_EXPAND, expand,
1061 g_free (title_markup);
1062 g_object_unref (link);
1064 child = poppler_index_iter_get_child (iter);
1066 build_tree (pdf_document, model, &tree_iter, child);
1067 poppler_index_iter_free (child);
1068 poppler_action_free (action);
1070 } while (poppler_index_iter_next (iter));
1073 static GtkTreeModel *
1074 pdf_document_links_get_links_model (EvDocumentLinks *document_links)
1076 PdfDocument *pdf_document = PDF_DOCUMENT (document_links);
1077 GtkTreeModel *model = NULL;
1078 PopplerIndexIter *iter;
1080 g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), NULL);
1082 iter = poppler_index_iter_new (pdf_document->document);
1083 /* Create the model if we have items*/
1085 model = (GtkTreeModel *) gtk_tree_store_new (EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS,
1090 build_tree (pdf_document, model, NULL, iter);
1091 poppler_index_iter_free (iter);
1098 pdf_document_links_get_links (EvDocumentLinks *document_links,
1101 PdfDocument *pdf_document;
1102 PopplerPage *poppler_page;
1103 GList *retval = NULL;
1104 GList *mapping_list;
1108 pdf_document = PDF_DOCUMENT (document_links);
1109 poppler_page = poppler_document_get_page (pdf_document->document,
1111 mapping_list = poppler_page_get_link_mapping (poppler_page);
1112 poppler_page_get_size (poppler_page, NULL, &height);
1114 for (list = mapping_list; list; list = list->next) {
1115 PopplerLinkMapping *link_mapping;
1116 EvLinkMapping *ev_link_mapping;
1118 link_mapping = (PopplerLinkMapping *)list->data;
1119 ev_link_mapping = g_new (EvLinkMapping, 1);
1120 ev_link_mapping->link = ev_link_from_action (pdf_document,
1121 link_mapping->action);
1122 ev_link_mapping->x1 = link_mapping->area.x1;
1123 ev_link_mapping->x2 = link_mapping->area.x2;
1124 /* Invert this for X-style coordinates */
1125 ev_link_mapping->y1 = height - link_mapping->area.y2;
1126 ev_link_mapping->y2 = height - link_mapping->area.y1;
1128 retval = g_list_prepend (retval, ev_link_mapping);
1131 poppler_page_free_link_mapping (mapping_list);
1132 g_object_unref (poppler_page);
1134 return g_list_reverse (retval);
1138 pdf_document_links_find_link_dest (EvDocumentLinks *document_links,
1139 const gchar *link_name)
1141 PdfDocument *pdf_document;
1143 EvLinkDest *ev_dest = NULL;
1145 pdf_document = PDF_DOCUMENT (document_links);
1146 dest = poppler_document_find_dest (pdf_document->document,
1149 ev_dest = ev_link_dest_from_dest (pdf_document, dest);
1150 poppler_dest_free (dest);
1157 pdf_document_document_links_iface_init (EvDocumentLinksIface *iface)
1159 iface->has_document_links = pdf_document_links_has_document_links;
1160 iface->get_links_model = pdf_document_links_get_links_model;
1161 iface->get_links = pdf_document_links_get_links;
1162 iface->find_link_dest = pdf_document_links_find_link_dest;
1166 pdf_document_images_get_images (EvDocumentImages *document_images,
1169 GList *retval = NULL;
1170 PdfDocument *pdf_document;
1171 PopplerPage *poppler_page;
1172 GList *mapping_list;
1175 pdf_document = PDF_DOCUMENT (document_images);
1176 poppler_page = poppler_document_get_page (pdf_document->document, page);
1177 mapping_list = poppler_page_get_image_mapping (poppler_page);
1179 for (list = mapping_list; list; list = list->next) {
1180 PopplerImageMapping *image_mapping;
1181 EvImageMapping *ev_image_mapping;
1183 image_mapping = (PopplerImageMapping *)list->data;
1185 ev_image_mapping = g_new (EvImageMapping, 1);
1187 ev_image_mapping->image = ev_image_new_from_pixbuf (image_mapping->image);
1188 ev_image_mapping->x1 = image_mapping->area.x1;
1189 ev_image_mapping->x2 = image_mapping->area.x2;
1190 ev_image_mapping->y1 = image_mapping->area.y1;
1191 ev_image_mapping->y2 = image_mapping->area.y2;
1193 retval = g_list_prepend (retval, ev_image_mapping);
1196 poppler_page_free_image_mapping (mapping_list);
1197 g_object_unref (poppler_page);
1203 pdf_document_document_images_iface_init (EvDocumentImagesIface *iface)
1205 iface->get_images = pdf_document_images_get_images;
1209 make_thumbnail_for_page (PdfDocument *pdf_document,
1210 PopplerPage *poppler_page,
1211 EvRenderContext *rc)
1216 pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document),
1217 rc, &width, &height);
1219 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
1221 gdk_pixbuf_fill (pixbuf, 0xffffffff);
1223 ev_document_fc_mutex_lock ();
1224 poppler_page_render_to_pixbuf (poppler_page, 0, 0,
1226 rc->scale, rc->rotation, pixbuf);
1227 ev_document_fc_mutex_unlock ();
1233 pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
1234 EvRenderContext *rc,
1237 PdfDocument *pdf_document;
1238 PopplerPage *poppler_page;
1240 GdkPixbuf *border_pixbuf;
1242 pdf_document = PDF_DOCUMENT (document_thumbnails);
1244 poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
1245 g_return_val_if_fail (poppler_page != NULL, NULL);
1247 pixbuf = poppler_page_get_thumbnail (poppler_page);
1249 /* There is no provided thumbnail. We need to make one. */
1250 pixbuf = make_thumbnail_for_page (pdf_document, poppler_page, rc);
1254 border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
1255 g_object_unref (pixbuf);
1256 pixbuf = border_pixbuf;
1259 g_object_unref (poppler_page);
1265 pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
1266 EvRenderContext *rc,
1270 PdfDocument *pdf_document;
1271 PopplerPage *poppler_page;
1274 pdf_document = PDF_DOCUMENT (document_thumbnails);
1275 poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
1277 g_return_if_fail (poppler_page != NULL);
1279 has_thumb = poppler_page_get_thumbnail_size (poppler_page, width, height);
1282 double page_width, page_height;
1284 poppler_page_get_size (poppler_page, &page_width, &page_height);
1286 *width = (gint) (page_width * rc->scale);
1287 *height = (gint) (page_height * rc->scale);
1290 if (rc->rotation == 90 || rc->rotation == 270) {
1298 g_object_unref (poppler_page);
1302 pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface)
1304 iface->get_thumbnail = pdf_document_thumbnails_get_thumbnail;
1305 iface->get_dimensions = pdf_document_thumbnails_get_dimensions;
1310 pdf_document_search_idle_callback (void *data)
1312 PdfDocumentSearch *search = (PdfDocumentSearch*) data;
1313 PdfDocument *pdf_document = search->document;
1318 page = poppler_document_get_page (search->document->document,
1319 search->search_page);
1321 ev_document_doc_mutex_lock ();
1322 matches = poppler_page_find_text (page, search->text);
1323 ev_document_doc_mutex_unlock ();
1325 g_object_unref (page);
1327 search->pages[search->search_page] = matches;
1328 ev_document_find_changed (EV_DOCUMENT_FIND (pdf_document),
1329 search->search_page);
1331 n_pages = pdf_document_get_n_pages (EV_DOCUMENT (search->document));
1332 search->search_page += 1;
1333 if (search->search_page == n_pages) {
1335 search->search_page = 0;
1338 if (search->search_page != search->start_page) {
1343 search->idle = 0; /* will return FALSE to remove */
1348 static PdfDocumentSearch *
1349 pdf_document_search_new (PdfDocument *pdf_document,
1353 PdfDocumentSearch *search;
1357 n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
1359 search = g_new0 (PdfDocumentSearch, 1);
1361 search->text = g_strdup (text);
1362 search->pages = g_new0 (GList *, n_pages);
1363 search->document = pdf_document;
1365 /* We add at low priority so the progress bar repaints */
1366 search->idle = g_idle_add_full (G_PRIORITY_LOW,
1367 pdf_document_search_idle_callback,
1371 search->start_page = start_page;
1372 search->search_page = start_page;
1378 pdf_document_find_begin (EvDocumentFind *document,
1380 const char *search_string,
1381 gboolean case_sensitive)
1383 PdfDocument *pdf_document = PDF_DOCUMENT (document);
1385 /* FIXME handle case_sensitive (right now XPDF
1386 * code is always case insensitive for ASCII
1387 * and case sensitive for all other languaages)
1390 if (pdf_document->search &&
1391 strcmp (search_string, pdf_document->search->text) == 0)
1394 if (pdf_document->search)
1395 pdf_document_search_free (pdf_document->search);
1397 pdf_document->search = pdf_document_search_new (pdf_document,
1403 pdf_document_find_get_n_results (EvDocumentFind *document_find, int page)
1405 PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
1408 return g_list_length (search->pages[page]);
1415 pdf_document_find_get_result (EvDocumentFind *document_find,
1418 EvRectangle *rectangle)
1420 PdfDocument *pdf_document = PDF_DOCUMENT (document_find);
1421 PdfDocumentSearch *search = pdf_document->search;
1422 PopplerPage *poppler_page;
1423 PopplerRectangle *r;
1429 r = (PopplerRectangle *) g_list_nth_data (search->pages[page],
1434 poppler_page = poppler_document_get_page (pdf_document->document, page);
1435 poppler_page_get_size (poppler_page, NULL, &height);
1436 rectangle->x1 = r->x1;
1437 rectangle->y1 = height - r->y2;
1438 rectangle->x2 = r->x2;
1439 rectangle->y2 = height - r->y1;
1440 g_object_unref (poppler_page);
1446 pdf_document_find_page_has_results (EvDocumentFind *document_find,
1449 PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
1451 return search && search->pages[page] != NULL;
1455 pdf_document_find_get_progress (EvDocumentFind *document_find)
1457 PdfDocumentSearch *search;
1458 int n_pages, pages_done;
1460 search = PDF_DOCUMENT (document_find)->search;
1462 if (search == NULL) {
1466 n_pages = pdf_document_get_n_pages (EV_DOCUMENT (document_find));
1467 if (search->search_page > search->start_page) {
1468 pages_done = search->search_page - search->start_page + 1;
1469 } else if (search->search_page == search->start_page) {
1470 pages_done = n_pages;
1472 pages_done = n_pages - search->start_page + search->search_page;
1475 return pages_done / (double) n_pages;
1479 pdf_document_find_cancel (EvDocumentFind *document)
1481 PdfDocument *pdf_document = PDF_DOCUMENT (document);
1483 if (pdf_document->search) {
1484 pdf_document_search_free (pdf_document->search);
1485 pdf_document->search = NULL;
1490 pdf_document_find_iface_init (EvDocumentFindIface *iface)
1492 iface->begin = pdf_document_find_begin;
1493 iface->get_n_results = pdf_document_find_get_n_results;
1494 iface->get_result = pdf_document_find_get_result;
1495 iface->page_has_results = pdf_document_find_page_has_results;
1496 iface->get_progress = pdf_document_find_get_progress;
1497 iface->cancel = pdf_document_find_cancel;
1500 static const gboolean supported_formats[] = {
1501 TRUE, /* EV_FILE_FORMAT_PS */
1502 #ifdef HAVE_CAIRO_PDF
1503 #ifdef HAVE_POPPLER_PAGE_RENDER
1504 TRUE, /* EV_FILE_FORMAT_PDF */
1506 FALSE, /* EV_FILE_FORMAT_PDF */
1512 pdf_print_context_free (PdfPrintContext *ctx)
1518 poppler_ps_file_free (ctx->ps_file);
1519 ctx->ps_file = NULL;
1521 #ifdef HAVE_CAIRO_PDF
1522 if (ctx->pdf_cairo) {
1523 cairo_destroy (ctx->pdf_cairo);
1524 ctx->pdf_cairo = NULL;
1531 pdf_document_file_exporter_format_supported (EvFileExporter *exporter,
1532 EvFileExporterFormat format)
1534 return supported_formats[format];
1538 pdf_document_file_exporter_begin (EvFileExporter *exporter,
1539 EvFileExporterFormat format,
1540 const char *filename,
1547 PdfDocument *pdf_document = PDF_DOCUMENT (exporter);
1548 PdfPrintContext *ctx;
1550 if (pdf_document->print_ctx)
1551 pdf_print_context_free (pdf_document->print_ctx);
1552 pdf_document->print_ctx = g_new0 (PdfPrintContext, 1);
1553 ctx = pdf_document->print_ctx;
1554 ctx->format = format;
1557 case EV_FILE_FORMAT_PS:
1558 ctx->ps_file = poppler_ps_file_new (pdf_document->document,
1559 filename, first_page,
1560 last_page - first_page + 1);
1561 poppler_ps_file_set_paper_size (ctx->ps_file, width, height);
1562 poppler_ps_file_set_duplex (ctx->ps_file, duplex);
1565 case EV_FILE_FORMAT_PDF: {
1566 #ifdef HAVE_CAIRO_PDF
1567 cairo_surface_t *surface;
1569 surface = cairo_pdf_surface_create (filename, width, height);
1570 ctx->pdf_cairo = cairo_create (surface);
1571 cairo_surface_destroy (surface);
1576 g_assert_not_reached ();
1581 pdf_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
1583 PdfDocument *pdf_document = PDF_DOCUMENT (exporter);
1584 PdfPrintContext *ctx = pdf_document->print_ctx;
1585 PopplerPage *poppler_page;
1587 g_return_if_fail (pdf_document->print_ctx != NULL);
1589 poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
1591 switch (ctx->format) {
1592 case EV_FILE_FORMAT_PS:
1593 poppler_page_render_to_ps (poppler_page, ctx->ps_file);
1595 case EV_FILE_FORMAT_PDF:
1596 #ifdef HAVE_CAIRO_PDF
1597 cairo_save (ctx->pdf_cairo);
1599 #ifdef HAVE_POPPLER_PAGE_RENDER
1600 poppler_page_render (poppler_page, ctx->pdf_cairo);
1602 #ifdef HAVE_CAIRO_PDF
1603 cairo_show_page (ctx->pdf_cairo);
1604 cairo_restore (ctx->pdf_cairo);
1608 g_assert_not_reached ();
1611 g_object_unref (poppler_page);
1615 pdf_document_file_exporter_end (EvFileExporter *exporter)
1617 PdfDocument *pdf_document = PDF_DOCUMENT (exporter);
1619 pdf_print_context_free (pdf_document->print_ctx);
1620 pdf_document->print_ctx = NULL;
1624 pdf_document_file_exporter_iface_init (EvFileExporterIface *iface)
1626 iface->format_supported = pdf_document_file_exporter_format_supported;
1627 iface->begin = pdf_document_file_exporter_begin;
1628 iface->do_page = pdf_document_file_exporter_do_page;
1629 iface->end = pdf_document_file_exporter_end;
1633 pdf_selection_render_selection (EvSelection *selection,
1634 EvRenderContext *rc,
1635 cairo_surface_t **surface,
1636 EvRectangle *points,
1637 EvRectangle *old_points,
1641 PdfDocument *pdf_document;
1642 double width_points, height_points;
1645 pdf_document = PDF_DOCUMENT (selection);
1646 set_rc_data (pdf_document, rc);
1648 poppler_page_get_size (POPPLER_PAGE (rc->data),
1649 &width_points, &height_points);
1650 width = (int) ((width_points * rc->scale) + 0.5);
1651 height = (int) ((height_points * rc->scale) + 0.5);
1654 #ifdef HAVE_POPPLER_PAGE_RENDER
1657 if (*surface == NULL) {
1658 *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1663 cr = cairo_create (*surface);
1664 cairo_scale (cr, rc->scale, rc->scale);
1665 cairo_surface_set_device_offset (*surface, 0, 0);
1666 memset (cairo_image_surface_get_data (*surface), 0x00,
1667 cairo_image_surface_get_height (*surface) *
1668 cairo_image_surface_get_stride (*surface));
1669 poppler_page_render_selection (POPPLER_PAGE (rc->data),
1671 (PopplerRectangle *)points,
1672 (PopplerRectangle *)old_points,
1673 POPPLER_SELECTION_NORMAL, /* SelectionStyle */
1677 #else /* HAVE_POPPLER_PAGE_RENDER */
1680 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
1684 poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data),
1685 rc->scale, rc->rotation, pixbuf,
1686 (PopplerRectangle *)points,
1687 (PopplerRectangle *)old_points,
1688 POPPLER_SELECTION_NORMAL, /* SelectionStyle */
1692 cairo_surface_destroy (*surface);
1693 *surface = ev_document_misc_surface_from_pixbuf (pixbuf);
1694 g_object_unref (pixbuf);
1695 #endif /* HAVE_POPPLER_PAGE_RENDER */
1700 pdf_selection_get_selection_region (EvSelection *selection,
1701 EvRenderContext *rc,
1702 EvRectangle *points)
1704 PdfDocument *pdf_document;
1707 pdf_document = PDF_DOCUMENT (selection);
1709 set_rc_data (pdf_document, rc);
1711 retval = poppler_page_get_selection_region ((PopplerPage *)rc->data,
1713 (PopplerRectangle *) points);
1718 pdf_selection_get_selection_map (EvSelection *selection,
1719 EvRenderContext *rc)
1721 PdfDocument *pdf_document;
1722 PopplerPage *poppler_page;
1723 PopplerRectangle points;
1726 pdf_document = PDF_DOCUMENT (selection);
1727 poppler_page = poppler_document_get_page (pdf_document->document,
1732 poppler_page_get_size (poppler_page, &(points.x2), &(points.y2));
1733 retval = poppler_page_get_selection_region (poppler_page, 1.0, &points);
1734 g_object_unref (poppler_page);
1740 pdf_selection_iface_init (EvSelectionIface *iface)
1742 iface->render_selection = pdf_selection_render_selection;
1743 iface->get_selection_region = pdf_selection_get_selection_region;
1744 iface->get_selection_map = pdf_selection_get_selection_map;
1747 /* Page Transitions */
1749 pdf_document_get_page_duration (EvDocumentTransition *trans,
1752 PdfDocument *pdf_document;
1753 PopplerPage *poppler_page;
1754 gdouble duration = -1;
1756 pdf_document = PDF_DOCUMENT (trans);
1757 poppler_page = poppler_document_get_page (pdf_document->document, page);
1761 duration = poppler_page_get_duration (poppler_page);
1762 g_object_unref (poppler_page);
1768 pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface)
1770 iface->get_page_duration = pdf_document_get_page_duration;
1774 pdf_document_new (void)
1776 return PDF_DOCUMENT (g_object_new (PDF_TYPE_DOCUMENT, NULL));