Description

  • ImagePDFMerger is a java applicaton that serves a very simple purpose - watch a directory, when images are placed in that directory, create a single PDF of those images. ImagePDFMerger uses the spring framework at its core, OpenSymphony Quartz to schedule the application and watch the directory, Apache FOP to create the PDF, MX4J to provide an open source implementation of JMX and castor to marshal objects to XML.
  • A typical scenario would be that you often have to send a number of images to possibly email customers, clients or your boss. Since you dont want to attach a number of seperate images, you just work out the images you want to send, copy them all to the directory which ImagePDFMerger watches on the network, and a few seconds later you're given a nicely formatted PDF generated from open source code.

Latest News & Announcements

  • Version 0.1 released

    Version 0.1 has been released of ImagePDFMerger has been released. Please use the download link above to download either the source or binary.

How Does It Work?

  • As mentioned in the description, at its core this application uses the Spring Framework. If you haven't been lucky enough to use the Spring Framework in your own applications check out www.springframework.org. The spring framework is responsible for scheduling a class that implements the org.imagepdfmerger.business.scheduledworkers.ScheduledWorker interface with the help of Quartz. While this class is being loaded into the scheduler, the MX4J http adaptor is also loaded. This gives you a way of primarily checking on the status of the application but also changing the configuration while the app is running. Once again spring is responsible for creating the MBean server and registering the MBeans.
  • So, once the application is all loaded, it watches a directory and waits for images to be placed there. It 'watches' the directory by being scheduled to run every x seconds and inspect the directory. Once new files are found, there is a delay as the app waits for the possibility of more files being places there. As the whole thing runs unattended its a little bit hit & miss as to whether the user has placed all the files in directory before the PDF generation occurs. But all the timing events are configurable via the spring context file. So you can schedule the app to check if there are any new files in the directory every 2 seconds, but once it sees a new file wait 120 seconds before checking again and if no new files are present, proceed to make the PDF.
  • So, you've placed some images in the watched directory, the application has seen it, what happens next? Well, for each image in the directory an Image object is created, the image hight and width is determined, that java.util.List of Image objects is marshaled to XML using Castor. This happens because the application uses XSL-FO and FOP to transform the XML into a so-called FO file and then a PDF document.
  • So thats basically it, FOP makes us the PDF file. As mentioned before you can check on the status of the application as its running in memory via your browser by just navigating to http://servername:port where servername is the name of the machine running the application and port is the port number as configured in the properties file.

Looks Good, But Setting It Looks Like It Would Be Difficult?!

  • Nah,.. thats just not true :). You've got a few things you'll need to make your mind up about though. You have to decide on the directory to watch, the time delays, and the port you want the http server to sit on. I've seperated out the configuration into 2 files. The first file is a properties file. The other is the spring context file. The properties file can be found in config\imagepdfmerger.properties and is where you configure the typical settings mentioned above. If you're interested in playing around with the app at a lower level, then the spring context file is what you want to edit. Thats it!
  • Oh, theres one other thing. Unfortunately due to licensening reasons *if* you want to merge png files, then you need to put jimi in the lib directory. If you're using the batch file that comes with the distribution, then you dont have to change anything else, just download Jimi from Sun. Just download the zip file, extract it and place JimiProClasses.zip in the lib directory.

How Do I Run It?

  • Easy! All you have to do is run the batch file which is included in the zip file which you can download via the link at the top right of this page. Just make sure you've got java 1.5+ installed.