Adverts
Rather conveniently FOP comes with a script and batch file that let you run it from the command line. Simply download the latest build of FOP and unpack it some where. If you are using Java 1.4 or later (which you can check with java -version on a command line) then get a version of FOP built for this platform.
Once FOP is downloaded and unpacked open a command line and cd to the directory where it is unpacked. Enter ./fop (these instructions assume you are running Linux or a flavour of Unix – the Windows instructions will be very similar). You should get a page or so of help with some examples of the script usage at the bottom.
Your First FOP Transformation
In order to test that everything is installed correctly and to show you the basics of XSLFO and FOP it is time to produce a simple PDF document. Exactly what is happening will be described in a moment but for now download this basic XSLFO document and then transform it using the command below:
./fop first-document.fo first-document.pdf
You might need to alter the path to the source document or the FOP script depending on where you currently are in the file system. Be careful not to name the output document first-document.fo (an easy mistake to make) FOP will just delete the XSLFO source document and then claim that it's unable to open the file. It would be nice if it checked to make sure the source and output files were different before it deleted the supposed output document.
Anyway, now that you have done the transformation you should have a file called first-document.pdf. You can check your version against our version of first-document.pdf to make sure they are the same.