Commit 038340fa authored by Marek Kasik's avatar Marek Kasik

glib: Make Duplex preference available in API

Add poppler_document_get_print_duplex() function and
PopplerPrintDuplex enum so that applications which
use poppler's glib frontend can access this preference.

poppler/poppler#290
parent fb05cab3
......@@ -2,7 +2,7 @@
* Copyright (C) 2005, Red Hat, Inc.
*
* Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
* Copyright (C) 2018 Marek Kasik <mkasik@redhat.com>
* Copyright (C) 2018-2019 Marek Kasik <mkasik@redhat.com>
* Copyright (C) 2019 Masamichi Hosoda <trueroad@trueroad.jp>
*
* This program is free software; you can redistribute it and/or modify
......@@ -81,7 +81,8 @@ enum {
PROP_VIEWER_PREFERENCES,
PROP_PERMISSIONS,
PROP_METADATA,
PROP_PRINT_SCALING
PROP_PRINT_SCALING,
PROP_PRINT_DUPLEX
};
static void poppler_document_layers_free (PopplerDocument *document);
......@@ -1652,6 +1653,50 @@ poppler_document_get_print_scaling (PopplerDocument *document)
return print_scaling;
}
/**
* poppler_document_get_print_duplex:
* @document: A #PopplerDocument
*
* Returns the duplex mode value suggested for printing by author of the document.
*
* Returns: a #PopplerPrintDuplex that should be used when document is printed
*
* Since: 0.78
**/
PopplerPrintDuplex
poppler_document_get_print_duplex (PopplerDocument *document)
{
Catalog *catalog;
ViewerPreferences *preferences;
PopplerPrintDuplex duplex = POPPLER_PRINT_DUPLEX_NONE;
g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), POPPLER_PRINT_DUPLEX_NONE);
catalog = document->doc->getCatalog ();
if (catalog && catalog->isOk ()) {
preferences = catalog->getViewerPreferences();
if (preferences) {
switch (preferences->getDuplex()) {
default:
case ViewerPreferences::Duplex::duplexNone:
duplex = POPPLER_PRINT_DUPLEX_NONE;
break;
case ViewerPreferences::Duplex::duplexSimplex:
duplex = POPPLER_PRINT_DUPLEX_SIMPLEX;
break;
case ViewerPreferences::Duplex::duplexDuplexFlipShortEdge:
duplex = POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_SHORT_EDGE;
break;
case ViewerPreferences::Duplex::duplexDuplexFlipLongEdge:
duplex = POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_LONG_EDGE;
break;
}
}
}
return duplex;
}
/**
* poppler_document_get_permissions:
* @document: A #PopplerDocument
......@@ -1885,6 +1930,9 @@ poppler_document_get_property (GObject *object,
case PROP_PRINT_SCALING:
g_value_set_enum (value, poppler_document_get_print_scaling (document));
break;
case PROP_PRINT_DUPLEX:
g_value_set_enum (value, poppler_document_get_print_duplex (document));
break;
case PROP_PERMISSIONS:
g_value_set_flags (value, poppler_document_get_permissions (document));
break;
......@@ -2166,6 +2214,20 @@ poppler_document_class_init (PopplerDocumentClass *klass)
POPPLER_PRINT_SCALING_APP_DEFAULT,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
/**
* PopplerDocument:print-duplex:
*
* Since: 0.78
*/
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_PRINT_DUPLEX,
g_param_spec_enum ("print-duplex",
"Print Duplex",
"Duplex Viewer Preference",
POPPLER_TYPE_PRINT_DUPLEX,
POPPLER_PRINT_DUPLEX_NONE,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
/**
* PopplerDocument:permissions:
*
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2004, Red Hat, Inc.
*
* Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
* Copyright (C) 2018 Marek Kasik <mkasik@redhat.com>
* Copyright (C) 2018-2019 Marek Kasik <mkasik@redhat.com>
* Copyright (C) 2019 Masamichi Hosoda <trueroad@trueroad.jp>
*
* This program is free software; you can redistribute it and/or modify
......@@ -152,6 +152,25 @@ typedef enum
POPPLER_PRINT_SCALING_NONE
} PopplerPrintScaling;
/**
* PopplerPrintDuplex:
* @POPPLER_PRINT_DUPLEX_NONE: No preference on duplex printing
* @POPPLER_PRINT_DUPLEX_SIMPLEX: Print single-sided
* @POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_SHORT_EDGE: Duplex and flip on the short edge of the sheet
* @POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_LONG_EDGE: Duplex and flip on the long edge of the sheet
*
* Duplex viewer preference
*
* Since: 0.78
*/
typedef enum
{
POPPLER_PRINT_DUPLEX_NONE,
POPPLER_PRINT_DUPLEX_SIMPLEX,
POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_SHORT_EDGE,
POPPLER_PRINT_DUPLEX_DUPLEX_FLIP_LONG_EDGE
} PopplerPrintDuplex;
/**
* PopplerPermissions:
* @POPPLER_PERMISSIONS_OK_TO_PRINT: document can be printer
......@@ -375,6 +394,8 @@ POPPLER_PUBLIC
gchar *poppler_document_get_metadata (PopplerDocument *document);
POPPLER_PUBLIC
PopplerPrintScaling poppler_document_get_print_scaling (PopplerDocument *document);
POPPLER_PUBLIC
PopplerPrintDuplex poppler_document_get_print_duplex (PopplerDocument *document);
/* Attachments */
POPPLER_PUBLIC
......
......@@ -175,6 +175,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_duplex
poppler_document_get_print_scaling
poppler_document_get_producer
poppler_document_get_subject
......@@ -248,6 +249,7 @@ POPPLER_TYPE_PDF_CONFORMANCE
POPPLER_TYPE_PDF_PART
POPPLER_TYPE_PDF_SUBTYPE
POPPLER_TYPE_PERMISSIONS
POPPLER_TYPE_PRINT_DUPLEX
POPPLER_TYPE_PRINT_SCALING
POPPLER_TYPE_PS_FILE
POPPLER_TYPE_VIEWER_PREFERENCES
......@@ -263,6 +265,7 @@ poppler_pdf_conformance_get_type
poppler_pdf_part_get_type
poppler_pdf_subtype_get_type
poppler_permissions_get_type
poppler_print_duplex_get_type
poppler_print_scaling_get_type
poppler_ps_file_get_type
poppler_viewer_preferences_get_type
......
......@@ -59,6 +59,7 @@ poppler_pdf_part_get_type
poppler_pdf_subtype_get_type
poppler_permissions_get_type
poppler_point_get_type
poppler_print_duplex_get_type
poppler_print_flags_get_type
poppler_print_scaling_get_type
poppler_ps_file_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