Am 26.04.2017 um 13:44 schrieb Olivier Cailloux:
Le 25/04/2017 à 18:43, Tilman Hausherr a écrit :
Am 25.04.2017 um 14:15 schrieb Olivier Cailloux:
Le 24/04/2017 à 20:10, Tilman Hausherr a écrit :
Am 24.04.2017 um 14:53 schrieb Olivier Cailloux:
Dear list,
How can I obtain, from a given PDDocument, a list of the page
label ranges that it contains?
Here is an example where I obtain the first PDPageLabelRange. How
to retrieve the other ones? I realize I can iterate over all pages
of the document and query for the possible existence of a
pageLabelRange at each page, but I suspect there must be a more
efficient (and simpler) way.
try (PDDocument document = PDDocument.load(…)) {
assert !document.isEncrypted();
PDDocumentCatalog catalog = document.getDocumentCatalog();
PDPageLabels labels = catalog.getPageLabels();
PDPageLabelRange pageLabelRange = labels.getPageLabelRange(0);
}
[accidentally mailed; repost for the list]
Do you need the range (which is a naming scheme) or do you need the
label?
Thanks for your reply. I need the ranges.
First one isn't available for some reason. There's a Map<Integer,
PDPageLabelRange> labels, but it is not available to the public.
Should I file a request for improving this situation somehow?
Olivier
I'm wondering whether it is really THAT important?
Certainly not extremely important. But still more elegant and nice to
have, me thinks. I suspect other users will wonder how to iterate over
the label ranges, as it seems a natural information to provide. (My
two cents.)
I'm not sure if I should expose the map; maybe return a list of pages
as a set? You could then iterate on that one to get the ranges.
A set of PDPageLabelRange in itself has low usefulness, as
PDPageLabelRange objects do not contain the corresponding page
indexes. I’d rather suggest providing a set of page indexes on which
PDPageLabelRange start. (Assuming you do not plan to change the rest
of the API.) This would fit well with the existing
labels.getPageLabelRange method. Or even better (IMHO), add the page
index info to the PDPageLabelRange object. I feel it belongs there.
The page label object mirrors the page label dictionary (see in the PDF
specification "Entries in a page label dictionary") so we won't add the
page number.
"I’d rather suggest providing a set of page indexes on which
PDPageLabelRange start."
That is what I meant, altough my words "maybe return a list of pages as
a set?" missed the word "indexes".
So, would this help you?
public Set<Integer>getPageIndices()
{
return labels.keySet();
}
Tilman
Olivier
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]