|
|
76f8c5 |
From 75f3d31daa050ca822d2ab501cdeca748ddf9d54 Mon Sep 17 00:00:00 2001
|
|
|
76f8c5 |
From: Marek Kasik <mkasik@redhat.com>
|
|
|
76f8c5 |
Date: Wed, 2 Jan 2019 14:55:41 +0100
|
|
|
76f8c5 |
Subject: glib: Make PrintScaling preference available in API
|
|
|
76f8c5 |
|
|
|
76f8c5 |
Add poppler_document_get_print_scaling() function and
|
|
|
76f8c5 |
PopplerPrintScaling enum so that applications which
|
|
|
76f8c5 |
use poppler's glib frontend can access this preference.
|
|
|
76f8c5 |
|
|
|
76f8c5 |
https://bugs.freedesktop.org/show_bug.cgi?id=92779
|
|
|
76f8c5 |
|
|
|
76f8c5 |
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
|
|
|
76f8c5 |
index d97d1448..ed37da4c 100644
|
|
|
76f8c5 |
--- a/glib/poppler-document.cc
|
|
|
76f8c5 |
+++ b/glib/poppler-document.cc
|
|
|
76f8c5 |
@@ -36,6 +37,7 @@
|
|
|
76f8c5 |
#include <FontInfo.h>
|
|
|
76f8c5 |
#include <PDFDocEncoding.h>
|
|
|
76f8c5 |
#include <OptionalContent.h>
|
|
|
76f8c5 |
+#include <ViewerPreferences.h>
|
|
|
76f8c5 |
#endif
|
|
|
76f8c5 |
|
|
|
76f8c5 |
#include "poppler.h"
|
|
|
76f8c5 |
@@ -78,7 +80,8 @@ enum {
|
|
|
76f8c5 |
PROP_PAGE_MODE,
|
|
|
76f8c5 |
PROP_VIEWER_PREFERENCES,
|
|
|
76f8c5 |
PROP_PERMISSIONS,
|
|
|
76f8c5 |
- PROP_METADATA
|
|
|
76f8c5 |
+ PROP_METADATA,
|
|
|
76f8c5 |
+ PROP_PRINT_SCALING
|
|
|
76f8c5 |
};
|
|
|
76f8c5 |
|
|
|
76f8c5 |
static void poppler_document_layers_free (PopplerDocument *document);
|
|
|
76f8c5 |
@@ -1516,6 +1519,44 @@ poppler_document_get_page_mode (PopplerDocument *document)
|
|
|
76f8c5 |
return POPPLER_PAGE_MODE_UNSET;
|
|
|
76f8c5 |
}
|
|
|
76f8c5 |
|
|
|
76f8c5 |
+/**
|
|
|
76f8c5 |
+ * poppler_document_get_print_scaling:
|
|
|
76f8c5 |
+ * @document: A #PopplerDocument
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * Returns the print scaling value suggested by author of the document.
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * Return value: a #PopplerPrintScaling that should be used when document is printed
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * Since: 0.26.5
|
|
|
76f8c5 |
+ **/
|
|
|
76f8c5 |
+PopplerPrintScaling
|
|
|
76f8c5 |
+poppler_document_get_print_scaling (PopplerDocument *document)
|
|
|
76f8c5 |
+{
|
|
|
76f8c5 |
+ Catalog *catalog;
|
|
|
76f8c5 |
+ ViewerPreferences *preferences;
|
|
|
76f8c5 |
+ PopplerPrintScaling print_scaling = POPPLER_PRINT_SCALING_APP_DEFAULT;
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
+ g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), POPPLER_PRINT_SCALING_APP_DEFAULT);
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
+ catalog = document->doc->getCatalog ();
|
|
|
76f8c5 |
+ if (catalog && catalog->isOk ()) {
|
|
|
76f8c5 |
+ preferences = catalog->getViewerPreferences();
|
|
|
76f8c5 |
+ if (preferences) {
|
|
|
76f8c5 |
+ switch (preferences->getPrintScaling()) {
|
|
|
76f8c5 |
+ default:
|
|
|
76f8c5 |
+ case ViewerPreferences::printScalingAppDefault:
|
|
|
76f8c5 |
+ print_scaling = POPPLER_PRINT_SCALING_APP_DEFAULT;
|
|
|
76f8c5 |
+ break;
|
|
|
76f8c5 |
+ case ViewerPreferences::printScalingNone:
|
|
|
76f8c5 |
+ print_scaling = POPPLER_PRINT_SCALING_NONE;
|
|
|
76f8c5 |
+ break;
|
|
|
76f8c5 |
+ }
|
|
|
76f8c5 |
+ }
|
|
|
76f8c5 |
+ }
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
+ return print_scaling;
|
|
|
76f8c5 |
+}
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
/**
|
|
|
76f8c5 |
* poppler_document_get_permissions:
|
|
|
76f8c5 |
* @document: A #PopplerDocument
|
|
|
76f8c5 |
@@ -1746,6 +1787,9 @@ poppler_document_get_property (GObject *object,
|
|
|
76f8c5 |
/* FIXME: write... */
|
|
|
76f8c5 |
g_value_set_flags (value, POPPLER_VIEWER_PREFERENCES_UNSET);
|
|
|
76f8c5 |
break;
|
|
|
76f8c5 |
+ case PROP_PRINT_SCALING:
|
|
|
76f8c5 |
+ g_value_set_enum (value, poppler_document_get_print_scaling (document));
|
|
|
76f8c5 |
+ break;
|
|
|
76f8c5 |
case PROP_PERMISSIONS:
|
|
|
76f8c5 |
g_value_set_flags (value, poppler_document_get_permissions (document));
|
|
|
76f8c5 |
break;
|
|
|
76f8c5 |
@@ -2013,6 +2057,20 @@ poppler_document_class_init (PopplerDocumentClass *klass)
|
|
|
76f8c5 |
POPPLER_VIEWER_PREFERENCES_UNSET,
|
|
|
76f8c5 |
G_PARAM_READABLE));
|
|
|
76f8c5 |
|
|
|
76f8c5 |
+ /**
|
|
|
76f8c5 |
+ * PopplerDocument:print-scaling:
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * Since: 0.26.5
|
|
|
76f8c5 |
+ */
|
|
|
76f8c5 |
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
76f8c5 |
+ PROP_PRINT_SCALING,
|
|
|
76f8c5 |
+ g_param_spec_enum ("print-scaling",
|
|
|
76f8c5 |
+ "Print Scaling",
|
|
|
76f8c5 |
+ "Print Scaling Viewer Preference",
|
|
|
76f8c5 |
+ POPPLER_TYPE_PRINT_SCALING,
|
|
|
76f8c5 |
+ POPPLER_PRINT_SCALING_APP_DEFAULT,
|
|
|
76f8c5 |
+ (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
/**
|
|
|
76f8c5 |
* PopplerDocument:permissions:
|
|
|
76f8c5 |
*
|
|
|
76f8c5 |
diff --git a/glib/poppler-document.h b/glib/poppler-document.h
|
|
|
76f8c5 |
index ebf3a9e1..e9eeebfd 100644
|
|
|
76f8c5 |
--- a/glib/poppler-document.h
|
|
|
76f8c5 |
+++ b/glib/poppler-document.h
|
|
|
76f8c5 |
@@ -135,6 +136,21 @@ typedef enum /*< flags >*/
|
|
|
76f8c5 |
POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL = 1 << 6
|
|
|
76f8c5 |
} PopplerViewerPreferences;
|
|
|
76f8c5 |
|
|
|
76f8c5 |
+/**
|
|
|
76f8c5 |
+ * PopplerPrintScaling:
|
|
|
76f8c5 |
+ * @POPPLER_PRINT_SCALING_APP_DEFAULT: application's default page scaling
|
|
|
76f8c5 |
+ * @POPPLER_PRINT_SCALING_NONE: no page scaling
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * PrintScaling viewer preference
|
|
|
76f8c5 |
+ *
|
|
|
76f8c5 |
+ * Since: 0.26.5
|
|
|
76f8c5 |
+ */
|
|
|
76f8c5 |
+typedef enum
|
|
|
76f8c5 |
+{
|
|
|
76f8c5 |
+ POPPLER_PRINT_SCALING_APP_DEFAULT,
|
|
|
76f8c5 |
+ POPPLER_PRINT_SCALING_NONE
|
|
|
76f8c5 |
+} PopplerPrintScaling;
|
|
|
76f8c5 |
+
|
|
|
76f8c5 |
/**
|
|
|
76f8c5 |
* PopplerPermissions:
|
|
|
76f8c5 |
* @POPPLER_PERMISSIONS_OK_TO_PRINT: document can be printer
|
|
|
76f8c5 |
@@ -356,6 +372,7 @@ POPPLER_PUBLIC
|
|
|
76f8c5 |
PopplerPageMode poppler_document_get_page_mode (PopplerDocument *document);
|
|
|
76f8c5 |
PopplerPermissions poppler_document_get_permissions (PopplerDocument *document);
|
|
|
76f8c5 |
gchar *poppler_document_get_metadata (PopplerDocument *document);
|
|
|
76f8c5 |
+PopplerPrintScaling poppler_document_get_print_scaling (PopplerDocument *document);
|
|
|
76f8c5 |
|
|
|
76f8c5 |
/* Attachments */
|
|
|
76f8c5 |
guint poppler_document_get_n_attachments (PopplerDocument *document);
|
|
|
76f8c5 |
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
|
|
|
76f8c5 |
index 39985553..c71c2776 100644
|
|
|
76f8c5 |
--- a/glib/reference/poppler-sections.txt
|
|
|
76f8c5 |
+++ b/glib/reference/poppler-sections.txt
|
|
|
76f8c5 |
@@ -174,6 +174,7 @@ poppler_document_get_pdf_subtype_string
|
|
|
76f8c5 |
poppler_document_get_page_layout
|
|
|
76f8c5 |
poppler_document_get_page_mode
|
|
|
76f8c5 |
poppler_document_get_permissions
|
|
|
76f8c5 |
+poppler_document_get_print_scaling
|
|
|
76f8c5 |
poppler_document_get_metadata
|
|
|
76f8c5 |
poppler_document_is_linearized
|
|
|
76f8c5 |
poppler_document_get_n_pages
|
|
|
76f8c5 |
@@ -246,6 +247,7 @@ POPPLER_TYPE_PDF_CONFORMANCE
|
|
|
76f8c5 |
POPPLER_TYPE_PAGE_LAYOUT
|
|
|
76f8c5 |
POPPLER_TYPE_PAGE_MODE
|
|
|
76f8c5 |
POPPLER_TYPE_PERMISSIONS
|
|
|
76f8c5 |
+POPPLER_TYPE_PRINT_SCALING
|
|
|
76f8c5 |
POPPLER_TYPE_VIEWER_PREFERENCES
|
|
|
76f8c5 |
|
|
|
76f8c5 |
<SUBSECTION Private>
|
|
|
76f8c5 |
@@ -260,6 +262,7 @@ poppler_pdf_conformance_get_type
|
|
|
76f8c5 |
poppler_page_layout_get_type
|
|
|
76f8c5 |
poppler_page_mode_get_type
|
|
|
76f8c5 |
poppler_permissions_get_type
|
|
|
76f8c5 |
+poppler_print_scaling_get_type
|
|
|
76f8c5 |
poppler_viewer_preferences_get_type
|
|
|
76f8c5 |
</SECTION>
|
|
|
76f8c5 |
|
|
|
76f8c5 |
diff --git a/glib/reference/poppler.types b/glib/reference/poppler.types
|
|
|
76f8c5 |
index 354fdd3a..2f7a3991 100644
|
|
|
76f8c5 |
--- a/glib/reference/poppler.types
|
|
|
76f8c5 |
+++ b/glib/reference/poppler.types
|
|
|
76f8c5 |
@@ -60,5 +60,6 @@ poppler_pdf_subtype_get_type
|
|
|
76f8c5 |
poppler_layer_get_type
|
|
|
76f8c5 |
poppler_media_get_type
|
|
|
76f8c5 |
poppler_movie_get_type
|
|
|
76f8c5 |
+poppler_print_scaling_get_type
|
|
|
76f8c5 |
poppler_structure_element_get_type
|
|
|
76f8c5 |
poppler_structure_element_iter_get_type
|