ArrayIndexOutOfBoundsException with extracting labels from malformed document
-----------------------------------------------------------------------------

                 Key: PDFBOX-900
                 URL: https://issues.apache.org/jira/browse/PDFBOX-900
             Project: PDFBox
          Issue Type: Bug
            Reporter: Kevin Jackson


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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to