pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Get list of PDPageLabelRange?
Date Mon, 24 Apr 2017 18:10:47 GMT
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? Last one would be easy.

       labels.getLabelsByPageIndices();

First one isn't available for some reason. There's a Map<Integer, 
PDPageLabelRange> labels, but it is not available to the public.

Tilman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message