summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6fa673e)
raw | patch | inline | side by side (parent: 6fa673e)
author | miklosh <miklosh@users.sourceforge.net> | |
Wed, 4 Jul 2007 00:05:18 +0000 (00:05 +0000) | ||
committer | miklosh <miklosh@users.sourceforge.net> | |
Wed, 4 Jul 2007 00:05:18 +0000 (00:05 +0000) |
configure.ac | patch | blob | history | |
src/extension/init.cpp | patch | blob | history | |
src/extension/internal/Makefile_insert | patch | blob | history | |
src/extension/internal/pdf-input-cairo.cpp | [new file with mode: 0644] | patch | blob |
src/extension/internal/pdf-input-cairo.h | [new file with mode: 0644] | patch | blob |
diff --git a/configure.ac b/configure.ac
index 6dab04287fadc8b5a5c05a034fdca52369d03a47..bae3fb78ccc145b0a294775fcbb1045eb0c22aa4 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_SUBST(LCMS_CFLAGS)
AC_SUBST(LCMS_LIBS)
+dnl ******************************
+dnl Libpoppler checking
+dnl ******************************
+
+POPPLER_CFLAGS=""
+PKG_CHECK_MODULES(POPPLER, poppler >= 0.5, poppler=yes, poppler=no)
+
+if test "x$poppler" = "xyes"; then
+ dnl Working libpoppler
+ POPPLER_LIBS="-lpoppler "
+ dnl Have to test libpoppler-glib presence
+ PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib >= 0.5, poppler_glib=yes, poppler_glib=no)
+ if test "x$poppler_glib" = "xyes"; then
+ dnl Working libpoppler-glib found
+ dnl Check whether the Cairo SVG backend is available
+ PKG_CHECK_MODULES(CAIRO_SVG, cairo-svg, cairo_svg=yes, cairo_svg=no)
+ if test "x$cairo_svg" = "xyes"; then
+ POPPLER_LIBS="$POPPLER_LIBS -lpoppler-glib "
+ fi
+ fi
+fi
+
+if test "x$poppler" = "xyes"; then
+ LIBS="$LIBS $POPPLER_LIBS"
+ AC_DEFINE(HAVE_POPPLER, 1, [Use libpoppler for direct PDF import])
+fi
+if test "x$poppler_glib" = "xyes" -a "x$cairo_svg" = "xyes"; then
+ AC_DEFINE(HAVE_POPPLER_GLIB, 1, [Use libpoppler-glib and Cairo-SVG for PDF import])
+fi
+AC_SUBST(POPPLER_CFLAGS)
+AC_SUBST(POPPLER_LIBS)
+
dnl ******************************
dnl Inkboard dependency checking
dnl ******************************
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 75f825f243d5d8f7508dc6b1945a3f61fb17f8b6..a8129fc8b30ea2f7774464ccd0d652db22393dbd 100644 (file)
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
# include "internal/cairo-png-out.h"
# include "internal/cairo-ps-out.h"
#endif
+#include "internal/pdf-input-cairo.h"
#include "internal/pov-out.h"
#include "internal/odf.h"
#include "internal/latex-pstricks-out.h"
}
Internal::CairoPsOutput::init();
#endif
+ Internal::PdfInputCairo::init();
#ifdef WITH_GNOME_PRINT
Internal::PrintGNOME::init();
#endif
index 6c4dc9556dfd6f6f5081062ecf6e4e64d2e16158..8886254dad8973d0f6248e51891022b014317e43 100644 (file)
extension/internal/ps-out.cpp \
extension/internal/pdf-cairo.cpp \
extension/internal/pdf-cairo.h \
+ extension/internal/pdf-input-cairo.cpp \
+ extension/internal/pdf-input-cairo.h \
extension/internal/cairo-pdf-out.h \
extension/internal/cairo-pdf-out.cpp \
extension/internal/cairo-ps-out.h \
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
--- /dev/null
@@ -0,0 +1,110 @@
+ /*
+ * Simple PDF import extension using libpoppler and Cairo's SVG surface.
+ *
+ * Authors:
+ * miklos erdelyi
+ *
+ * Copyright (C) 2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_POPPLER_GLIB
+
+#include "pdf-input-cairo.h"
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include <cairo-svg.h>
+#include <poppler/glib/poppler.h>
+#include <poppler/glib/poppler-document.h>
+#include <poppler/glib/poppler-page.h>
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+static cairo_status_t _write_ustring_cb(void *closure, const unsigned char *data, unsigned int length);
+
+SPDocument *
+PdfInputCairo::open(Inkscape::Extension::Input * mod, const gchar * uri) {
+
+ gchar* filename_uri = g_filename_to_uri(uri, NULL, NULL);
+
+ PopplerDocument* document = poppler_document_new_from_file(filename_uri, NULL, NULL);
+ if (document == NULL)
+ return NULL;
+
+ double width, height;
+ PopplerPage* page = poppler_document_get_page(document, 0);
+ poppler_page_get_size(page, &width, &height);
+
+ Glib::ustring* output = new Glib::ustring("");
+ cairo_surface_t* surface = cairo_svg_surface_create_for_stream(Inkscape::Extension::Internal::_write_ustring_cb,
+ output, width, height);
+ cairo_t* cr = cairo_create(surface);
+
+ poppler_page_render(page, cr);
+ cairo_show_page(cr);
+
+ cairo_destroy(cr);
+ cairo_surface_destroy(surface);
+
+ SPDocument * doc = sp_document_new_from_mem(output->c_str(), output->length(), TRUE);
+
+ delete output;
+ g_object_unref(page);
+ g_object_unref(document);
+
+ return doc;
+}
+
+static cairo_status_t
+ _write_ustring_cb(void *closure, const unsigned char *data, unsigned int length)
+{
+ Glib::ustring* stream = (Glib::ustring*)closure;
+ stream->append((const char*)data, length);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+
+#include "clear-n_.h"
+
+void
+PdfInputCairo::init(void) {
+ Inkscape::Extension::Extension * ext;
+
+ ext = Inkscape::Extension::build_from_mem(
+ "<inkscape-extension>\n"
+ "<name>PDF Input</name>\n"
+ "<id>org.inkscape.input.pdf</id>\n"
+ "<input>\n"
+ "<extension>.pdf</extension>\n"
+ "<mimetype>application/pdf</mimetype>\n"
+ "<filetypename>Adobe PDF (*.pdf)</filetypename>\n"
+ "<filetypetooltip>PDF Document</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new PdfInputCairo());
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* HAVE_POPPLER_GLIB */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __EXTENSION_INTERNAL_PDFINPUTCAIRO_H__
+#define __EXTENSION_INTERNAL_PDFINPUTCAIRO_H__
+
+/*
+ * PDF input using libpoppler and Cairo's SVG surface.
+ *
+ * Authors:
+ * miklos erdelyi
+ *
+ * Copyright (C) 2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_POPPLER_GLIB
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class PdfInputCairo: public Inkscape::Extension::Implementation::Implementation {
+ PdfInputCairo () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* HAVE_POPPLER_GLIB */
+
+#endif /* __EXTENSION_INTERNAL_PDFINPUTCAIRO_H__ */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :