#include <poppler.h>
#include <poppler-document.h>
#include <poppler-page.h>
+#ifdef HAVE_CAIRO_PDF
#include <cairo-pdf.h>
+#endif
#include <glib/gi18n.h>
#include "ev-poppler.h"
#include "ev-document-fonts.h"
#include "ev-document-security.h"
#include "ev-document-thumbnails.h"
+#include "ev-document-transition.h"
#include "ev-selection.h"
#include "ev-attachment.h"
typedef struct {
EvFileExporterFormat format;
PopplerPSFile *ps_file;
+#ifdef HAVE_CAIRO_PDF
cairo_t *pdf_cairo;
+#endif
} PdfPrintContext;
struct _PdfDocumentClass
static void pdf_document_find_iface_init (EvDocumentFindIface *iface);
static void pdf_document_file_exporter_iface_init (EvFileExporterIface *iface);
static void pdf_selection_iface_init (EvSelectionIface *iface);
+static void pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface);
static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
gint page,
gint size,
pdf_document_file_exporter_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_SELECTION,
pdf_selection_iface_init);
+ G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_TRANSITION,
+ pdf_document_page_transition_iface_init);
});
width, height);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
+ ev_document_fc_mutex_lock ();
poppler_page_render_to_pixbuf (poppler_page, 0, 0,
width, height,
scale, rotation, pixbuf);
+ ev_document_fc_mutex_unlock ();
g_object_unref (poppler_page);
static const gboolean supported_formats[] = {
TRUE, /* EV_FILE_FORMAT_PS */
+#ifdef HAVE_CAIRO_PDF
#ifdef HAVE_POPPLER_PAGE_RENDER
TRUE, /* EV_FILE_FORMAT_PDF */
#else
FALSE, /* EV_FILE_FORMAT_PDF */
#endif
+#endif
};
static void
poppler_ps_file_free (ctx->ps_file);
ctx->ps_file = NULL;
}
-
+#ifdef HAVE_CAIRO_PDF
if (ctx->pdf_cairo) {
cairo_destroy (ctx->pdf_cairo);
ctx->pdf_cairo = NULL;
}
-
+#endif
g_free (ctx);
}
break;
case EV_FILE_FORMAT_PDF: {
+#ifdef HAVE_CAIRO_PDF
cairo_surface_t *surface;
surface = cairo_pdf_surface_create (filename, width, height);
ctx->pdf_cairo = cairo_create (surface);
cairo_surface_destroy (surface);
+#endif
}
break;
default:
#ifdef HAVE_POPPLER_PAGE_RENDER
poppler_page_render (poppler_page, ctx->pdf_cairo);
#endif
+#ifdef HAVE_CAIRO_PDF
cairo_show_page (ctx->pdf_cairo);
+#endif
break;
default:
g_assert_not_reached ();
iface->get_selection_map = pdf_selection_get_selection_map;
}
+/* Page Transitions */
+static gdouble
+pdf_document_get_page_duration (EvDocumentTransition *trans,
+ gint page)
+{
+#ifdef HAVE_POPPLER_PAGE_GET_DURATION
+ PdfDocument *pdf_document;
+ PopplerPage *poppler_page;
+ gdouble duration = -1;
+
+ pdf_document = PDF_DOCUMENT (trans);
+ poppler_page = poppler_document_get_page (pdf_document->document, page);
+ if (!poppler_page)
+ return -1;
+
+ duration = poppler_page_get_duration (poppler_page);
+ g_object_unref (poppler_page);
+
+ return duration;
+#else
+ return -1;
+#endif /* HAVE_POPPLER_PAGE_GET_DURATION */
+}
+
+static void
+pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface)
+{
+ iface->get_page_duration = pdf_document_get_page_duration;
+}
+
PdfDocument *
pdf_document_new (void)
{