[
https://issues.apache.org/jira/browse/PDFBOX-5880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17884548#comment-17884548
]
Tilman Hausherr commented on PDFBOX-5880:
-----------------------------------------
proposed change is to add {{stream.setLong(COSName.LENGTH, streamLength);}} or
change the foreach loop that it doesn't overwrite the length entry.
> 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
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-5880
> URL: https://issues.apache.org/jira/browse/PDFBOX-5880
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 2.0.32, 3.0.3 PDFBox
> Reporter: Joseph Jezerinac
> Priority: Major
> Labels: regression
> Attachments: test.pdf
>
>
> When rendering page one of the attached PDF the image does not render.
> In the logs, I see the following:
> {noformat}
> 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)
> {noformat}
> I assume this is a bad PDF, but Acrobat, Chrome, etc., display it without an
> issue.
> Here's the render code used:
> {code:java}
> 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);
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]