glib/poppler-document.cc | 60 +++++++++++++++++++++++++++++++++++- glib/poppler-document.h | 17 ++++++++++ glib/reference/poppler-sections.txt | 3 + glib/reference/poppler.types | 1 4 files changed, 80 insertions(+), 1 deletion(-)
New commits: commit 75f3d31daa050ca822d2ab501cdeca748ddf9d54 Author: Marek Kasik <[email protected]> Date: Wed Jan 2 14:55:41 2019 +0100 glib: Make PrintScaling preference available in API Add poppler_document_get_print_scaling() function and PopplerPrintScaling enum so that applications which use poppler's glib frontend can access this preference. https://bugs.freedesktop.org/show_bug.cgi?id=92779 diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index d97d1448..ed37da4c 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -2,6 +2,7 @@ * Copyright (C) 2005, Red Hat, Inc. * * Copyright (C) 2016 Jakub Alba <[email protected]> + * Copyright (C) 2018 Marek Kasik <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +37,7 @@ #include <FontInfo.h> #include <PDFDocEncoding.h> #include <OptionalContent.h> +#include <ViewerPreferences.h> #endif #include "poppler.h" @@ -78,7 +80,8 @@ enum { PROP_PAGE_MODE, PROP_VIEWER_PREFERENCES, PROP_PERMISSIONS, - PROP_METADATA + PROP_METADATA, + PROP_PRINT_SCALING }; static void poppler_document_layers_free (PopplerDocument *document); @@ -1517,6 +1520,44 @@ poppler_document_get_page_mode (PopplerDocument *document) } /** + * poppler_document_get_print_scaling: + * @document: A #PopplerDocument + * + * Returns the print scaling value suggested by author of the document. + * + * Return value: a #PopplerPrintScaling that should be used when document is printed + * + * Since: 0.73 + **/ +PopplerPrintScaling +poppler_document_get_print_scaling (PopplerDocument *document) +{ + Catalog *catalog; + ViewerPreferences *preferences; + PopplerPrintScaling print_scaling = POPPLER_PRINT_SCALING_APP_DEFAULT; + + g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), POPPLER_PRINT_SCALING_APP_DEFAULT); + + catalog = document->doc->getCatalog (); + if (catalog && catalog->isOk ()) { + preferences = catalog->getViewerPreferences(); + if (preferences) { + switch (preferences->getPrintScaling()) { + default: + case ViewerPreferences::PrintScaling::printScalingAppDefault: + print_scaling = POPPLER_PRINT_SCALING_APP_DEFAULT; + break; + case ViewerPreferences::PrintScaling::printScalingNone: + print_scaling = POPPLER_PRINT_SCALING_NONE; + break; + } + } + } + + return print_scaling; +} + +/** * poppler_document_get_permissions: * @document: A #PopplerDocument * @@ -1746,6 +1787,9 @@ poppler_document_get_property (GObject *object, /* FIXME: write... */ g_value_set_flags (value, POPPLER_VIEWER_PREFERENCES_UNSET); break; + case PROP_PRINT_SCALING: + g_value_set_enum (value, poppler_document_get_print_scaling (document)); + break; case PROP_PERMISSIONS: g_value_set_flags (value, poppler_document_get_permissions (document)); break; @@ -2014,6 +2058,20 @@ poppler_document_class_init (PopplerDocumentClass *klass) G_PARAM_READABLE)); /** + * PopplerDocument:print-scaling: + * + * Since: 0.73 + */ + g_object_class_install_property (G_OBJECT_CLASS (klass), + PROP_PRINT_SCALING, + g_param_spec_enum ("print-scaling", + "Print Scaling", + "Print Scaling Viewer Preference", + POPPLER_TYPE_PRINT_SCALING, + POPPLER_PRINT_SCALING_APP_DEFAULT, + (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS))); + + /** * PopplerDocument:permissions: * * Flags specifying which operations are permitted when the document is opened diff --git a/glib/poppler-document.h b/glib/poppler-document.h index ebf3a9e1..e9eeebfd 100644 --- a/glib/poppler-document.h +++ b/glib/poppler-document.h @@ -2,6 +2,7 @@ * Copyright (C) 2004, Red Hat, Inc. * * Copyright (C) 2016 Jakub Alba <[email protected]> + * Copyright (C) 2018 Marek Kasik <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -136,6 +137,21 @@ typedef enum /*< flags >*/ } PopplerViewerPreferences; /** + * PopplerPrintScaling: + * @POPPLER_PRINT_SCALING_APP_DEFAULT: application's default page scaling + * @POPPLER_PRINT_SCALING_NONE: no page scaling + * + * PrintScaling viewer preference + * + * Since: 0.73 + */ +typedef enum +{ + POPPLER_PRINT_SCALING_APP_DEFAULT, + POPPLER_PRINT_SCALING_NONE +} PopplerPrintScaling; + +/** * PopplerPermissions: * @POPPLER_PERMISSIONS_OK_TO_PRINT: document can be printer * @POPPLER_PERMISSIONS_OK_TO_MODIFY: document contents can be modified @@ -356,6 +372,7 @@ POPPLER_PUBLIC PopplerPDFConformance poppler_document_get_pdf_conformance (PopplerDocument *document); POPPLER_PUBLIC gchar *poppler_document_get_metadata (PopplerDocument *document); +PopplerPrintScaling poppler_document_get_print_scaling (PopplerDocument *document); /* Attachments */ POPPLER_PUBLIC diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 39985553..c71c2776 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -174,6 +174,7 @@ poppler_document_get_pdf_subtype_string poppler_document_get_pdf_version poppler_document_get_pdf_version_string poppler_document_get_permissions +poppler_document_get_print_scaling poppler_document_get_producer poppler_document_get_subject poppler_document_get_title @@ -246,6 +247,7 @@ POPPLER_TYPE_PDF_CONFORMANCE POPPLER_TYPE_PDF_PART POPPLER_TYPE_PDF_SUBTYPE POPPLER_TYPE_PERMISSIONS +POPPLER_TYPE_PRINT_SCALING POPPLER_TYPE_PS_FILE POPPLER_TYPE_VIEWER_PREFERENCES poppler_document_get_type @@ -260,6 +262,7 @@ poppler_pdf_conformance_get_type poppler_pdf_part_get_type poppler_pdf_subtype_get_type poppler_permissions_get_type +poppler_print_scaling_get_type poppler_ps_file_get_type poppler_viewer_preferences_get_type </SECTION> diff --git a/glib/reference/poppler.types b/glib/reference/poppler.types index 354fdd3a..2f7a3991 100644 --- a/glib/reference/poppler.types +++ b/glib/reference/poppler.types @@ -60,6 +60,7 @@ poppler_pdf_subtype_get_type poppler_permissions_get_type poppler_point_get_type poppler_print_flags_get_type +poppler_print_scaling_get_type poppler_ps_file_get_type poppler_quadrilateral_get_type poppler_rectangle_get_type _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
