Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1029

Patch for ArrayIndexOutOfBound Exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.6.0
    • Component/s: PDModel
    • Labels:

      Description

      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;
      }

        Attachments

          Activity

            People

            • Assignee:
              lehmi Andreas Lehmkühler
              Reporter:
              javakarthick karthick
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: