'PDFBox render image misses content
When using PDFBox, we encounter an issue where if we call render
on a PDDocument, it sometimes loses content, such as fonts or certain shapes.
Having dug into this, it looks to be caused by the use of SoftReference
throughout the PDFBox code base. The JVM seems to reap the underlying contents of the PDDocument while it's attempting to render the image. As a result, we see org.apache.pdfbox.cos.COSDocument - Warning: You did not close a PDF Document
at random intervals.
Has anyone else encountered this issue? If so, how was it solved? So far, our solution has been to write the contents to a file, then read and render.
Solution 1:[1]
I had a similar issue. The PDF contained an image which was not rendered. The result was just a plain white BufferedImage.
Including the JBIG2 library (see https://pdfbox.apache.org/2.0/dependencies.html) to my classpath and updating the PDFBox-version from 2.0.15 to 2.0.26 solved the issue for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |