JPedal getPageAsImage() returns incomplete images

508 views Asked by At

I have a bunch of PDF files created by iText which i want to convert to images. I'm using JPedal to do so and it works in 99% of the cases but sometimes the images are incomplete. That means the content of forms or tables is missing or if the page contains only a picture (scan of a page) the resulting image is completely blank.

I have noticed that this only happens if the PDF file contains scanned pages. These are not exactly A4 like the rest of the document.

I tried to read the files with iText, create a new one in a temporary bytearray which contains only A4 pages and give this to JPedal. Also i set flattening to true. But nothing has changed.

Any ideas what causes this problem?

EDIT: I'm using jpedal-lgpl.jar in version 4.70. I searched for a more recent package and found version 4.92b23. With this one the content of forms gets converted correctly but the scanned pages are still blank with parts that look like what old TVs show when they have no signal.

I'd love to use the newest version but i can't find a download link. Did IDR Solutions stop publishing a lgpl version?

2

There are 2 answers

11
Lonzak On

Did you use the flattening functionality of iText or of jPedal?

The "classic" jpedal LGPL version stopped since version 4.92b23. The first version not released under LGPL was 4.93 and later 5.0. The author removed it completely from sourceforge a while ago which contradicts the open source idea imho but that is another story...

However depending on the java version you are using there is a new LGPL JPedal. Instead of Swing/AWT it uses JavaFX but you can still transform your images like before. So if you can use Java 1.8 then you can use that LGPL version and see if that fixes your problem...

Update: To fix the problems with your forms you can also flatten with jpedal: -Dorg.jpedal.flattenForm=true (or System.setProperty("org.jpedal.flattenForm","true"); )

One last possibility which comes to mind would be to fiddle around with the other jpedal options: https://www.idrsolutions.com/jpedal/support/jvm-flags/

Do you have the possibility to supply such an problematic PDF file for analysis?

0
TomB On

We are paying customer of JPedal and we stumbled accross some threading issues some while ago. The problem got fixed quite quickly by IDR.

Try rendering in a synchronized block and see if the problem still persists.