You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "karthick (JIRA)" <ji...@apache.org> on 2011/06/03 07:46:47 UTC
[jira] [Updated] (PDFBOX-1029) Patch for ArrayIndexOutOfBound
Exception
[ https://issues.apache.org/jira/browse/PDFBOX-1029?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
karthick updated PDFBOX-1029:
-----------------------------
Attachment: PageLabelError.pdf
> 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
> Labels: patch
> Fix For: 1.6.0
>
> Attachments: PageLabelError.pdf
>
>
> 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