Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading FOP images from database

My application generates PDFs using images stored in the EAR. The images are changed about on a monthly basis, and I would like to move them into the database to avoid deployment by every image file change.

Unforunately there is a problem:

<fo:block>
           <fo:external-graphic src=”testImage.gif”/>
</fo:block>

The FOP can just accept URL as parameter. I could create a servlet that reads the database and can give an image and then I could refer to the servlet url from the FOP context, but I think it is not the best solution. An other solution would be storing the images in the file system and recording the filenames in the database, but I do like none of these options. What do you think about these solutions? Is there any third one? Thanks Zoltan

like image 320
HamoriZ Avatar asked Jan 28 '26 06:01

HamoriZ


1 Answers

I think your servlet option is probably the best.

Here's another option, not sure if it is a good one. Store the images in the database with the filename as the primary key. During application startup, pull all the images out of the database and write them to the given filenames in the appropriate location so that the FOP logic can locate them.

Either the application would need to be restarted whenever an image is changed in the database, or you would need to add a method of forcing it to refresh the image files on disk.

like image 132
Dave Costa Avatar answered Jan 29 '26 19:01

Dave Costa