Commit 75f3d31d authored by Marek Kasik's avatar Marek Kasik Committed by Albert Astals Cid

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
parent 44505cb3
......@@ -2,6 +2,7 @@
* Copyright (C) 2005, Red Hat, Inc.
*
* Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
* Copyright (C) 2018 Marek Kasik <mkasik@redhat.com>
*
* 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);
......@@ -1516,6 +1519,44 @@ poppler_document_get_page_mode (PopplerDocument *document)
return POPPLER_PAGE_MODE_UNSET;
}
/**
* 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;
......@@ -2013,6 +2057,20 @@ poppler_document_class_init (PopplerDocumentClass *klass)
POPPLER_VIEWER_PREFERENCES_UNSET,
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:
*
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2004, Red Hat, Inc.
*
* Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
* Copyright (C) 2018 Marek Kasik <mkasik@redhat.com>
*
* 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
......@@ -135,6 +136,21 @@ typedef enum /*< flags >*/
POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL = 1 << 6
} 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
......@@ -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
......
......@@ -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>
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment