0
votes

I wanted to render image on PDF which is going to generated by FOP. To render image I am using tag <fo:external-graphic> As below :

<fo:external-graphic src="url('../offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8')" inline-progression-dimension.maximum="100%"  content-height="scale-down-to-fit" content-width="scale-down-to-fit"> </fo:external-graphic>

I also tried by giving full URL as:

<fo:external-graphic src="http://10.2.10.79/Web/offlinePaper/displayImage?disImg=e391d672-ebf4-44d8-86cb-2cf987a50bf7" inline-progression-dimension.maximum="100%"  content-height="scale-down-to-fit" content-width="scale-down-to-fit"> </fo:external-graphic>

In controller I am having an request mapping (../offlinePaper/displayImage) which takes image name disImg from getParameter and decrypt the image and return in OutputStream.

But when I generate PDF I found Error in log file as:

Image not available. URI: http://10.2.10.79:80/Web/offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for http://10.2.10.79:80/Web/offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8 (No context info available)

But if I copy this URL and paste in URL then image get shown in browser and I also found that when I generate PDF the request mapping which is suppose to get call for image decryption is not getting called.

Update

Also a strange think I come to know that with same code PDF get successfully generated if web server is Tomcat but if I deploy application on Glassfish it's giving error.

1
I have a similar problem only for images generated by jsp and i use Outputstream too. Did you only changed the web server or have you made other chages in the code? This is my question stackoverflow.com/questions/24768480/image-not-displayed-on-pdfFernando Prieto
@FernandoPrieto, no I just changed server. currently I solved this by writing URIResolver.Amogh

1 Answers

0
votes

In the exception trace stands:

ImageException: The file format is not supported

The FO seems to be able to find an ImagePreloader according to file extension. If it doesn't find any, it breaks.

I'd propose to change the way how the url is built. There should be a real image file name included.

So, instead of:

../offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8

try

../offlinePaper/displayImage/disImg4bec89f0-5b97-40c3-b7c9-ac555a664df8.jpg