[
https://issues.apache.org/jira/browse/PDFBOX-900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14311291#comment-14311291
]
Tilman Hausherr commented on PDFBOX-900:
----------------------------------------
Just for the record - I had to delete the test file in PDFBOX-2383 because it
isn't apache licensed. The code used the create the new file is:
{code}
PDDocument doc = new PDDocument();
doc.addPage(new PDPage());
doc.addPage(new PDPage());
doc.addPage(new PDPage());
doc.addPage(new PDPage());
PDPageLabels pl = new PDPageLabels(doc);
PDPageLabelRange plr0 = new PDPageLabelRange();
plr0.setPrefix("bad");
PDPageLabelRange plr1 = new PDPageLabelRange();
plr1.setPrefix("one");
PDPageLabelRange plr2 = new PDPageLabelRange();
plr2.setPrefix("two");
pl.setLabelItem(-1, plr0);
pl.setLabelItem(0, plr1);
pl.setLabelItem(1, plr2);
doc.getDocumentCatalog().setPageLabels(pl);
doc.save("badpagelabels.pdf");
{code}
> ArrayIndexOutOfBoundsException with extracting labels from malformed document
> -----------------------------------------------------------------------------
>
> Key: PDFBOX-900
> URL: https://issues.apache.org/jira/browse/PDFBOX-900
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.3.1
> Reporter: Kevin Jackson
> Assignee: Adam Nichols
> Fix For: 1.4.0
>
> Attachments: page_label.pdf
>
>
> This document opens fine in Adobe Reader but inside there is a negative page
> label offset. This results in an ArrayIndexOutOfBoundsException in
> getLabelsByPageIndices() in PDFBox
> My patch is to ignore that page label.
> ### Eclipse Workspace Patch 1.0
> #P pdfbox
> Index: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java
> ===================================================================
> --- pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java
> (revision 1026306)
> +++ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java
> (working copy)
> @@ -108,7 +108,9 @@
> Map<Integer, COSDictionary> numbers = node.getNumbers();
> for (Entry<Integer, COSDictionary> i : numbers.entrySet())
> {
> - labels.put(i.getKey(), new PDPageLabelRange(i.getValue()));
> + if (i.getKey() >= 0) {
> + labels.put(i.getKey(), new
> PDPageLabelRange(i.getValue()));
> + }
> }
> }
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]