Patch for ArrayIndexOutOfBound Exception
----------------------------------------
Key: PDFBOX-1029
URL: https://issues.apache.org/jira/browse/PDFBOX-1029
Project: PDFBox
Issue Type: Bug
Components: PDModel
Affects Versions: 1.5.0
Reporter: karthick
Fix For: 1.6.0
This document opens fine in Adobe Reader.While extracting page labels from
getLabelsByPageIndices() i got the below exception
java.lang.ArrayIndexOutOfBoundsException: 3
at
org.apache.pdfbox.pdmodel.common.PDPageLabels$2.newLabel(PDPageLabels.java:218)
at
org.apache.pdfbox.pdmodel.common.PDPageLabels.computeLabels(PDPageLabels.java:252)
at
org.apache.pdfbox.pdmodel.common.PDPageLabels.getLabelsByPageIndices(PDPageLabels.java:214)
ORIGINAL CODE IN PDPageLabels.java
public String[] getLabelsByPageIndices()
{
final String[] map = new String[doc.getNumberOfPages()];
computeLabels(new LabelHandler()
{
public void newLabel(int pageIndex, String label)
{
map[pageIndex] = label;
}
});
return map;
}
It works fine with the below modified code in PDPageLabels.java
MODIFIED CODE IN PDPageLabels.java
public String[] getLabelsByPageIndices()
{
final String[] map = new String[doc.getNumberOfPages()];
computeLabels(new LabelHandler()
{
public void newLabel(int pageIndex, String label)
{
if(pageIndex < doc.getNumberOfPages()){
map[pageIndex] = label;
}
}
});
return map;
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira