Display an image of the first page of a pdf file.
GTK3 only.
for thumbnailing camera video clips
disable with configure option: --disable-ffmpegthumbnailer
+ libpoppler-glib-dev 0.62
+ for displaying pdf files
+ disable with configure option: --disable-pdf
+
### Code hackers:
If you plan on making any major changes to the code that will be offered for
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_LIBS)
+# Pdf support
+# ----------------------------------------------------------------------
+
+if test "x${gtk3}" != "xno"; then
+ AC_ARG_ENABLE([pdf],
+ AC_HELP_STRING([--disable-pdf], [disable pdf support]),
+ [libpdf=$enableval], [libpdf=auto])
+
+ if test "x${libpdf}" != "xno"; then
+ PKG_CHECK_MODULES(PDF, poppler-glib >= 0.62,
+ [
+ HAVE_PDF=yes
+ AC_DEFINE(HAVE_PDF, 1, [define to enable pdf support])
+ ],
+ [
+ HAVE_PDF=no
+ AC_MSG_WARN([$PDF_PKG_ERRORS])
+ ])
+ else
+ HAVE_PDF=disabled
+ fi
+else
+ HAVE_PDF=disabled
+fi
+
+AM_CONDITIONAL(HAVE_PDF, [test "x$HAVE_PDF" = xyes])
+AC_SUBST(PDF_CFLAGS)
+AC_SUBST(PDF_LIBS)
+
# Markdown support
# ----------------------------------------------------------------------
Libchamplain-gtk: $HAVE_LIBCHAMPLAIN_GTK
Lua: $HAVE_LUA
FFmpegthumbnailer: $HAVE_FFMPEGTHUMBNAILER
+ Pdf: $HAVE_PDF
Documentation:
Doxygen: $DX_DOXYGEN
$(CLUTTER_CFLAGS) \
$(CLUTTER_GTK_CFLAGS) \
$(FFMPEGTHUMBNAILER_CFLAGS) \
+ $(PDF_CFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir)
$(CLUTTER_CFLAGS) \
$(CLUTTER_GTK_CFLAGS) \
$(FFMPEGTHUMBNAILER_CFLAGS) \
+ $(PDF_CFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir)
image_load_dds.h\
image_load_collection.c\
image_load_collection.h\
+ image_load_pdf.c\
+ image_load_pdf.h\
image_load_ffmpegthumbnailer.c\
image_load_ffmpegthumbnailer.h\
image-overlay.c \
zonedetect.c \
zonedetect.h
-geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS) $(LUA_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(FFMPEGTHUMBNAILER_LIBS)
+geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS) $(LUA_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(FFMPEGTHUMBNAILER_LIBS) $(PDF_LIBS)
EXTRA_DIST = \
$(extra_SLIK)
/* other supported formats */
filter_add_if_missing("dds", "DirectDraw Surface", ".dds", FORMAT_CLASS_IMAGE, FALSE, FALSE, TRUE);
+ filter_add_if_missing("pdf", "Portable Document Format", ".pdf", FORMAT_CLASS_PDF, FALSE, FALSE, TRUE);
}
GList *filter_to_list(const gchar *extensions)
if (filter_file_class(name, FORMAT_CLASS_META)) return FORMAT_CLASS_META;
if (filter_file_class(name, FORMAT_CLASS_VIDEO)) return FORMAT_CLASS_VIDEO;
if (filter_file_class(name, FORMAT_CLASS_COLLECTION)) return FORMAT_CLASS_COLLECTION;
+ if (filter_file_class(name, FORMAT_CLASS_PDF)) return FORMAT_CLASS_PDF;
return FORMAT_CLASS_UNKNOWN;
}
icon_exif.png \
icon_marks.png \
icon_info.png \
- icon_sort.png
+ icon_sort.png \
+ icon_pdf.png
ICONS_INLINE_PAIRS = \
folder_closed $(srcdir)/folder_closed.png \
icon_exif $(srcdir)/icon_exif.png \
icon_marks $(srcdir)/icon_marks.png \
icon_info $(srcdir)/icon_info.png \
- icon_sort $(srcdir)/icon_sort.png
+ icon_sort $(srcdir)/icon_sort.png \
+ icon_pdf $(srcdir)/icon_pdf.png
icons_inline.h: $(ICONS_INLINE) Makefile.in
@sh -ec "echo '/* Auto generated file, do not edit */'; echo; \
#include "image_load_jpeg.h"
#include "image_load_tiff.h"
#include "image_load_dds.h"
+#include "image_load_pdf.h"
#include "image_load_ffmpegthumbnailer.h"
#include "image_load_collection.h"
}
else
#endif
+#ifdef HAVE_PDF
+ if (il->fd->format_class == FORMAT_CLASS_PDF)
+ {
+ DEBUG_1("Using custom pdf loader");
+ image_loader_backend_set_pdf(&il->backend);
+ }
+ else
+#endif
#ifdef HAVE_JPEG
if (il->bytes_total >= 2 && il->mapped_file[0] == 0xff && il->mapped_file[1] == 0xd8)
{
case FORMAT_CLASS_COLLECTION:
pixbuf = pixbuf_inline(PIXBUF_INLINE_COLLECTION);
break;
+ case FORMAT_CLASS_PDF:
+ pixbuf = pixbuf_inline(PIXBUF_INLINE_ICON_PDF);
+ break;
default:
pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN);
}
--- /dev/null
+/*
+ * Copyright (C) 20018 - The Geeqie Team
+ *
+ * Author: Colin Clark
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "main.h"
+
+#include "image-load.h"
+#include "image_load_pdf.h"
+
+#ifdef HAVE_PDF
+#include <poppler/glib/poppler.h>
+
+typedef struct _ImageLoaderPDF ImageLoaderPDF;
+struct _ImageLoaderPDF {
+ ImageLoaderBackendCbAreaUpdated area_updated_cb;
+ ImageLoaderBackendCbSize size_cb;
+ ImageLoaderBackendCbAreaPrepared area_prepared_cb;
+ gpointer data;
+ GdkPixbuf *pixbuf;
+ guint requested_width;
+ guint requested_height;
+ gboolean abort;
+};
+
+static gboolean image_loader_pdf_load(gpointer loader, const guchar *buf, gsize count, GError **error)
+{
+ ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoader *il = ld->data;
+ GError *poppler_error;
+ gchar *uri;
+ PopplerPage *page;
+ PopplerDocument *document;
+ gint page_num;
+ gdouble width, height;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gboolean ret = FALSE;
+
+ uri = g_filename_to_uri(il->fd->path, NULL, &poppler_error);
+ if (uri == NULL)
+ {
+ log_printf("warning: pdf reader error: %s\n", poppler_error->message);
+ }
+ else
+ {
+ page_num = 0;
+ document = poppler_document_new_from_file(uri, NULL, &poppler_error);
+ page = poppler_document_get_page(document, page_num);
+ poppler_page_get_size(page, &width, &height);
+
+ surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create(surface);
+ poppler_page_render(page, cr);
+
+ ld->pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height);
+ ld->area_updated_cb(loader, 0, 0, width, height, ld->data);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy(surface);
+ g_free(uri);
+ g_object_unref(page);
+ g_object_unref(document);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+static gpointer image_loader_pdf_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
+{
+ ImageLoaderPDF *loader = g_new0(ImageLoaderPDF, 1);
+ loader->area_updated_cb = area_updated_cb;
+ loader->size_cb = size_cb;
+ loader->area_prepared_cb = area_prepared_cb;
+ loader->data = data;
+ return (gpointer) loader;
+}
+
+static void image_loader_pdf_set_size(gpointer loader, int width, int height)
+{
+ ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ld->requested_width = width;
+ ld->requested_height = height;
+}
+
+static GdkPixbuf* image_loader_pdf_get_pixbuf(gpointer loader)
+{
+ ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ return ld->pixbuf;
+}
+
+static gchar* image_loader_pdf_get_format_name(gpointer loader)
+{
+ return g_strdup("pdf");
+}
+
+static gchar** image_loader_pdf_get_format_mime_types(gpointer loader)
+{
+ static gchar *mime[] = {"application/pdf", NULL};
+ return g_strdupv(mime);
+}
+
+static gboolean image_loader_pdf_close(gpointer loader, GError **error)
+{
+ return TRUE;
+}
+
+static void image_loader_pdf_abort(gpointer loader)
+{
+ ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ld->abort = TRUE;
+}
+
+static void image_loader_pdf_free(gpointer loader)
+{
+ ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ if (ld->pixbuf) g_object_unref(ld->pixbuf);
+ g_free(ld);
+}
+
+void image_loader_backend_set_pdf(ImageLoaderBackend *funcs)
+{
+ funcs->loader_new = image_loader_pdf_new;
+ funcs->set_size = image_loader_pdf_set_size;
+ funcs->load = image_loader_pdf_load;
+ funcs->write = NULL;
+ funcs->get_pixbuf = image_loader_pdf_get_pixbuf;
+ funcs->close = image_loader_pdf_close;
+ funcs->abort = image_loader_pdf_abort;
+ funcs->free = image_loader_pdf_free;
+ funcs->get_format_name = image_loader_pdf_get_format_name;
+ funcs->get_format_mime_types = image_loader_pdf_get_format_mime_types;
+}
+
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- /dev/null
+/*
+ * Copyright (C) 20018 - The Geeqie Team
+ *
+ * Author: Colin Clark
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef IMAGE_LOAD_PDF_H
+#define IMAGE_LOAD_PDF_H
+
+#ifdef HAVE_PDF
+void image_loader_backend_set_pdf(ImageLoaderBackend *funcs);
+#endif
+
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
{ PIXBUF_INLINE_ICON_MARKS, icon_marks },
{ PIXBUF_INLINE_ICON_INFO, icon_info },
{ PIXBUF_INLINE_ICON_SORT, icon_sort },
+ { PIXBUF_INLINE_ICON_PDF, icon_pdf },
{ NULL, NULL }
};
case FORMAT_CLASS_COLLECTION:
pixbuf = pixbuf_inline(PIXBUF_INLINE_COLLECTION);
break;
+ case FORMAT_CLASS_PDF:
+ pixbuf = pixbuf_inline(PIXBUF_INLINE_ICON_PDF);
+ break;
default:
pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN);
}
#define PIXBUF_INLINE_ICON_MARKS "icon_marks"
#define PIXBUF_INLINE_ICON_INFO "icon_info"
#define PIXBUF_INLINE_ICON_SORT "icon_sort"
+#define PIXBUF_INLINE_ICON_PDF "icon_pdf"
GdkPixbuf *pixbuf_copy_rotate_90(GdkPixbuf *src, gboolean counter_clockwise);
GdkPixbuf *pixbuf_copy_mirror(GdkPixbuf *src, gboolean mirror, gboolean flip);
N_("RAW Image"),
N_("Metadata"),
N_("Video"),
- N_("Collection")
+ N_("Collection"),
+ N_("Pdf")
};
/* config memory values */
if (!tl->fd) tl->fd = file_data_ref(fd);
- if (tl->fd->format_class != FORMAT_CLASS_IMAGE && tl->fd->format_class != FORMAT_CLASS_RAWIMAGE && tl->fd->format_class != FORMAT_CLASS_COLLECTION && tl->fd->format_class != FORMAT_CLASS_VIDEO && !options->file_filter.disable)
+ if (tl->fd->format_class != FORMAT_CLASS_IMAGE && tl->fd->format_class != FORMAT_CLASS_RAWIMAGE && tl->fd->format_class != FORMAT_CLASS_COLLECTION && tl->fd->format_class != FORMAT_CLASS_VIDEO && tl->fd->format_class != FORMAT_CLASS_PDF && !options->file_filter.disable)
{
thumb_loader_set_fallback(tl);
return FALSE;
tl->fd = file_data_ref(fd);
- if (!stat_utf8(fd->path, &st) || (tl->fd->format_class != FORMAT_CLASS_IMAGE && tl->fd->format_class != FORMAT_CLASS_RAWIMAGE && tl->fd->format_class != FORMAT_CLASS_VIDEO && tl->fd->format_class != FORMAT_CLASS_COLLECTION && !options->file_filter.disable))
+ if (!stat_utf8(fd->path, &st) || (tl->fd->format_class != FORMAT_CLASS_IMAGE && tl->fd->format_class != FORMAT_CLASS_RAWIMAGE && tl->fd->format_class != FORMAT_CLASS_VIDEO && tl->fd->format_class != FORMAT_CLASS_COLLECTION && tl->fd->format_class != FORMAT_CLASS_PDF && !options->file_filter.disable))
{
thumb_loader_std_set_fallback(tl);
return FALSE;
FORMAT_CLASS_META,
FORMAT_CLASS_VIDEO,
FORMAT_CLASS_COLLECTION,
+ FORMAT_CLASS_PDF,
FILE_FORMAT_CLASSES
} FileFormatClass;