[evince/wip/chpe/load-fd: 146/148] pdf: Implement loading from file descriptor
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/chpe/load-fd: 146/148] pdf: Implement loading from file descriptor
- Date: Tue, 13 Nov 2018 02:43:54 +0000 (UTC)
commit d96aace557932be38d2653d40cae2ef431d30aa3
Author: Christian Persch <chpe src gnome org>
Date: Fri Aug 24 21:21:44 2018 +0200
pdf: Implement loading from file descriptor
backend/pdf/ev-poppler.cc | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 32ca1dfe..febc9b90 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
/* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2018, Evangelos Rigas <erigas rnd2 org>
@@ -28,6 +27,7 @@
#include <poppler.h>
#include <poppler-document.h>
#include <poppler-page.h>
+#include <poppler-features.h>
#ifdef HAVE_CAIRO_PDF
#include <cairo-pdf.h>
#endif
@@ -68,6 +68,12 @@
#define HAVE_CAIRO_PRINT
#endif
+#if POPPLER_CHECK_VERSION (0, 67, 0)
+#define HAVE_POPPLER_LOAD_FD
+#else
+#error too old
+#endif
+
/* fields from the XMP Rights Management Schema, XMP Specification Sept 2005, pag. 45 */
#define LICENSE_MARKED "/rdf:RDF/rdf:Description/xmpRights:Marked"
#define LICENSE_TEXT "/rdf:RDF/rdf:Description/dc:rights/rdf:Alt/rdf:li[lang('%s')]"
@@ -345,6 +351,32 @@ pdf_document_load_gfile (EvDocument *document,
return TRUE;
}
+#ifdef HAVE_POPPLER_LOAD_FD
+static gboolean
+pdf_document_load_fd (EvDocument *document,
+ int fd,
+ EvDocumentLoadFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GError *err = NULL;
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+
+ /* Note: this consumes @fd */
+ pdf_document->document =
+ poppler_document_new_from_fd (fd,
+ pdf_document->password,
+ &err);
+
+ if (pdf_document->document == NULL) {
+ convert_error (err, error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+#endif
+
static int
pdf_document_get_n_pages (EvDocument *document)
{
@@ -1238,6 +1270,9 @@ pdf_document_class_init (PdfDocumentClass *klass)
ev_document_class->get_info = pdf_document_get_info;
ev_document_class->get_backend_info = pdf_document_get_backend_info;
ev_document_class->support_synctex = pdf_document_support_synctex;
+#ifdef HAVE_POPPLER_LOAD_FD
+ ev_document_class->load_fd = pdf_document_load_fd;
+#endif
}
/* EvDocumentSecurity */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]