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

renderImage IndexOutOfBoundsException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.4
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When processing the attached PDF the renderImage fails due to the exception below. This doesn't occur on other PDFs that I have tried, so perhaps its a problem with the file?

      The processing logic fails early on so it can be simplified to

      try (PDDocument document = PDDocument.load(file)) {
        for (int i = 0; i < document.getNumberOfPages(); i++) {
          PDFRenderer pdfRenderer = new PDFRenderer(document);
          BufferedImage image = pdfRenderer.renderImageWithDPI(i, 200);
          ...
        }
      }
      
      java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
      	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      	at java.util.ArrayList.get(ArrayList.java:429)
      	at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
      	at org.apache.pdfbox.rendering.PageDrawer.getAnnotationBorder(PageDrawer.java:987)
      	at org.apache.pdfbox.rendering.PageDrawer.drawAnnotationLinkBorder(PageDrawer.java:1039)
      	at org.apache.pdfbox.rendering.PageDrawer.showAnnotation(PageDrawer.java:960)
      	at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:193)
      	at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:145)
      	at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:80)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ben.manes Ben Manes
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: