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

Patch for ArrayIndexOutOfBound Exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0
    • PDModel

    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

        1. PageLabelError.pdf
          19 kB
          karthick

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: