No imagePreloader found - XML to PDF using FOP

2.4k views Asked by At

I'm trying to create PDFs from xml data. I'm using Apache FOP 1.1 for Java in Windows. The application runs perfectly in the Eclipse, but when I try to run it from the exported .jar images are not placed in the PDF. I've tryied running it at the cdm in order to see the log of the runtime. Here is the exception:

GRAVE: Image not available. URI: out/iberdrola.png. Reason: org.apache.xmlgraphics.
     image.loader.ImageException: The file format is not supported. No ImagePreloader
     found for out/iberdrola.png (No context info available) org.apache.xmlgraphics.
     image.loader.ImageException: The file format is not supported. 
     No ImagePreloader found for out/iberdrola.png
at org.apache.xmlgraphics.image.loader.ImageManager.preloadImage(ImageManager.java:180)

I've to explain that even if it's an exception, the program runs until the end and the PDF is rendered but without the image.

I've tryied some different ways to solve the problem, but no success. Much of the information I've googled relates to servelts, but I'm not programming a servelt. By the way, here I give you two different solutions that have worked to some others. They are related but I spect the procedure is different. I don't know how to try them, could anyone explain me those better? Even if they are explained there must be any step I'm missing.

http://apache-fop.1065347.n5.nabble.com/FOP-1-0-images-fail-to-render-td7348.html

Apache FOP in a Java Applet - No ImagePreloader found for data

I'm also open to any other solution to this problem.

Thanks in advice! Have a nice code!

1

There are 1 answers

1
MuGiK On BEST ANSWER

I finally came out with the solution. I don't know exactly wich of the two steps I made was the one that solved everything, but here it is.

Firstly, I changed the libraries of the project. I realised that the fop_1.1.jar I was using wasn't the official one provided by Apache. So I went to the official site and I downloaded the binary version. I added to my buildpath the fop library and the rest of dependent libraries of the folder called 'lib'.

Then, I increased the compilation version of Java. I was using the 1.4 version and many of the libs used require 1.5 or above. So as I realised that most of the computers nowadays use 1.7 or above I set it to 1.7.

I can't tell you which of the two solutions made this miracle, but for further projects I will check before that I'm using the correct libraries and that I have to check the minimum compilation version.

Have a nice code!