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

PDF render blank page: The end of the stream doesn't point to the correct offset, using workaround to read the stream, stream start position: 196, length: 0, expected end position: 196

    XMLWordPrintableJSON

Details

    Description

      When rendering page one of the attached PDF the image does not render.

      In the logs, I see the following:

      2024-09-24 13:25:56:924 [main] WARN COSParser - The end of the stream doesn't point to the correct offset, using workaround to read the stream, stream start position: 196, length: 0, expected end position: 196
      2024-09-24 13:25:56:930 [main] WARN PDFStreamEngine - Image stream is empty
      java.io.IOException: Image stream is empty
      	at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:182)
      	at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:477)
      	at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:438)
      	at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1107)
      

      I assume this is a bad PDF, but Acrobat, Chrome, etc., display it without an issue.

      Here's the render code used:

      File out = File.createTempFile("test-", ".png");
      PDDocument pdDocument = Loader.loadPDF(pdf);
      final PDFRenderer pdfRenderer = new PDFRenderer(pdDocument);
      ImageIO.write(pdfRenderer.renderImageWithDPI(0, 300), "png", out);
      

      Attachments

        1. test.pdf
          1.31 MB
          Joseph Jezerinac
        2. PDFBOX-1094-PDFBOX-269.pdf
          220 kB
          Tilman Hausherr

        Activity

          People

            lehmi Andreas Lehmkühler
            jezerinac Joseph Jezerinac
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: