Commit 18afdb2e authored by Marek Kasik's avatar Marek Kasik
Browse files

glib: Make PrintPageRange preference available in API

Add poppler_document_get_print_page_ranges() so that applications which
use poppler's glib frontend can access this preference.

poppler/poppler#290
parent 40ec62ce
......@@ -1775,6 +1775,50 @@ poppler_page_range_free (PopplerPageRange *range)
g_slice_free (PopplerPageRange, range);
}
/**
* poppler_document_get_print_page_ranges:
* @document: A #PopplerDocument
* @n_ranges: (out): return location for number of ranges
*
* Returns the suggested page ranges to print in the form of array
* of #PopplerPageRanges and number of ranges.
*
* Returns: (array length=n_ranges) (transfer full): an array
* of #PopplerPageRanges or NULL. Free the array when
* it is no longer needed.
*
* Since: 0.78
**/
PopplerPageRange *
poppler_document_get_print_page_ranges (PopplerDocument *document,
int *n_ranges)
{
Catalog *catalog;
ViewerPreferences *preferences;
std::vector<std::pair<int, int>> ranges;
PopplerPageRange *result = nullptr;
*n_ranges = 0;
g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL);
catalog = document->doc->getCatalog ();
if (catalog && catalog->isOk ()) {
preferences = catalog->getViewerPreferences ();
if (preferences) {
ranges = preferences->getPrintPageRange ();
*n_ranges = ranges.size ();
result = g_new (PopplerPageRange, ranges.size ());
for (guint i = 0; i < ranges.size (); ++i) {
result[i].start_page = ranges[i].first;
result[i].end_page = ranges[i].second;
}
}
}
return result;
}
/**
* poppler_document_get_permissions:
* @document: A #PopplerDocument
......
......@@ -398,6 +398,9 @@ POPPLER_PUBLIC
PopplerPrintDuplex poppler_document_get_print_duplex (PopplerDocument *document);
POPPLER_PUBLIC
gint poppler_document_get_print_n_copies (PopplerDocument *document);
POPPLER_PUBLIC
PopplerPageRange *poppler_document_get_print_page_ranges (PopplerDocument *document,
int *n_ranges);
/* Attachments */
POPPLER_PUBLIC
......
......@@ -177,6 +177,7 @@ poppler_document_get_pdf_version_string
poppler_document_get_permissions
poppler_document_get_print_duplex
poppler_document_get_print_n_copies
poppler_document_get_print_page_ranges
poppler_document_get_print_scaling
poppler_document_get_producer
poppler_document_get_subject
......
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