summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6fc7f42)
raw | patch | inline | side by side (parent: 6fc7f42)
author | miklosh <miklosh@users.sourceforge.net> | |
Sun, 18 Nov 2007 12:45:23 +0000 (12:45 +0000) | ||
committer | miklosh <miklosh@users.sourceforge.net> | |
Sun, 18 Nov 2007 12:45:23 +0000 (12:45 +0000) |
src/extension/internal/pdfinput/pdf-input.cpp | patch | blob | history | |
src/extension/internal/pdfinput/pdf-input.h | patch | blob | history |
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index a2b4fba48ab002bcf3cd3af09526d70023dd854d..2d6a8ea4be24909407fb3dd704bd3fc2f5fef384 100644 (file)
#include "Page.h"
#include "Catalog.h"
+#ifdef HAVE_POPPLER_CAIRO
+#include <poppler/glib/poppler.h>
+#include <poppler/glib/poppler-document.h>
+#include <poppler/glib/poppler-page.h>
+#endif
+
#include "pdf-input.h"
#include "extension/system.h"
#include "extension/input.h"
Glib::ustring(_("art box"))
};
-PdfImportDialog::PdfImportDialog(PDFDoc *doc)
+PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
{
_pdf_doc = doc;
_render_thumb = false;
#ifdef HAVE_POPPLER_CAIRO
- // Create an OutputDev
- _preview_output_dev = new CairoOutputDev();
- _preview_output_dev->startDoc(_pdf_doc->getXRef());
_cairo_surface = NULL;
_render_thumb = true;
+ // Create PopplerDocument
+ gchar *doc_uri = g_filename_to_uri(uri, NULL, NULL);
+ if (doc_uri) {
+ _poppler_doc = poppler_document_new_from_file(doc_uri, NULL, NULL);
+ g_free(doc_uri);
+ }
#endif
// Set default preview size
PdfImportDialog::~PdfImportDialog() {
#ifdef HAVE_POPPLER_CAIRO
- if (_preview_output_dev) {
- delete _preview_output_dev;
- }
if (_cairo_surface) {
cairo_surface_destroy(_cairo_surface);
}
+ if (_poppler_doc) {
+ g_object_unref(G_OBJECT(_poppler_doc));
+ }
#endif
if (_thumb_data) {
if (_render_thumb) {
cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); // Set fill color to white
cairo_paint(cr); // Clear it
cairo_scale(cr, scale_factor, scale_factor); // Use Cairo for resizing the image
- _preview_output_dev->setCairo(cr);
// Render page
- _previewed_page->displaySlice(_preview_output_dev,
- 72.0, 72.0, 0,
- FALSE, /* useMediaBox */
- TRUE, /* crop */
- 0, 0,
- (int)ceil(_previewed_page->getCropWidth()),
- (int)ceil(_previewed_page->getCropHeight()),
- FALSE, /* printing */
- _pdf_doc->getCatalog());
+ if (_poppler_doc != NULL) {
+ PopplerPage *poppler_page = poppler_document_get_page(_poppler_doc, page-1);
+ poppler_page_render(poppler_page, cr);
+ g_object_unref(G_OBJECT(poppler_page));
+ }
// Clean up
- _preview_output_dev->setCairo(NULL);
cairo_destroy(cr);
// Redraw preview area
_previewArea->set_size_request(_preview_width, _preview_height);
return NULL;
}
- PdfImportDialog *dlg = new PdfImportDialog(pdf_doc);
+ PdfImportDialog *dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
delete dlg;
delete pdf_doc;
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 83eecef62700244174f5d8e667e27de43491e5e0..3f545a8d0737d0fd8456e11be384b409e6f280d5 100644 (file)
#include "PDFDoc.h"
#ifdef HAVE_POPPLER_CAIRO
-#include <CairoOutputDev.h>
+#include <poppler/glib/poppler-document.h>
#endif
namespace Inkscape {
class PdfImportDialog : public Gtk::Dialog
{
public:
- PdfImportDialog(PDFDoc *doc);
+ PdfImportDialog(PDFDoc *doc, const gchar *uri);
virtual ~PdfImportDialog();
bool showDialog();
bool _render_thumb; // Whether we can/shall render thumbnails
#ifdef HAVE_POPPLER_CAIRO
cairo_surface_t *_cairo_surface;
- CairoOutputDev *_preview_output_dev;
+ PopplerDocument *_poppler_doc;
#endif
};