What is the difference between getPageLabels and getPageLabelFormats?
Under what circumstances could two calls return arrays of different lengths?
I have a program that calls PdfPageLabels.getPageLabels()
and PdfPageLabels.getPageLabelFormats()
on the same PdfReader
object on successive lines of my code:
PdfPageLabels.PdfPageLabelFormat[] pplf = PdfPageLabels.getPageLabelFormats(reader); String[] labs = PdfPageLabels.getPageLabels(reader);
I have an example. It's a 150Mb PDF file which appears to have 4670 labels via getPageLabels()
, but only 1 via getPageLabelFormats()
. So my question is: Under what circumstances could the two calls return arrays of different lengths?
Posted on StackOverflow on Dec 3, 2015 by paulb
There is no getPageLabelFormats()
method in iText 7. To learn the answer for your question, please, follow this link.
If you want to get the page labels, you should now use this code:
PdfReader reader = new PdfReader(src);
PdfDocument pdfDoc = new PdfDocument(reader);
String[] pageLabels = pdfDoc.getPageLabels();
The PageLabelNumberingStyleConstants
enumeration in iText 7 can be used when creating page labels like this:
pdfDoc.getPage(4).setPageLabel(PageLabelNumberingStyleConstants.DECIMAL_ARABIC_NUMERALS, "Custom-", 2);
Inspect the createPdf()
method in PageLabels
example to learn more.