[evince/wip/chpe/load-fd: 5/5] 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: 5/5] pdf: Implement loading from file descriptor
- Date: Thu, 6 Jan 2022 13:59:56 +0000 (UTC)
commit 913873247224cff27230e5ea57e10691e383b355
Author: Christian Persch <chpe src gnome org>
Date: Wed Dec 1 21:25:02 2021 +0100
pdf: Implement loading from file descriptor
backend/pdf/ev-poppler.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/backend/pdf/ev-poppler.c b/backend/pdf/ev-poppler.c
index 27c9a2e8e..852ccdcf0 100644
--- a/backend/pdf/ev-poppler.c
+++ b/backend/pdf/ev-poppler.c
@@ -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>
@@ -31,6 +30,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
@@ -72,6 +72,10 @@
#define HAVE_CAIRO_PRINT
#endif
+#if POPPLER_CHECK_VERSION (21, 12, 0)
+#define HAVE_POPPLER_LOAD_FD
+#endif
+
/* Fields for checking the license info suggested by Creative Commons
* Main reference: http://wiki.creativecommons.org/XMP */
@@ -354,6 +358,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)
{
@@ -1223,6 +1253,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]