There are three primary ways to run FOP from the command line depending on your input files:
1. Batch processing FO files
Use this when you already have a generated .fo file.
java org.apache.fop.apps.CommandLine fo-file pdf-file
2. Batch processing XML files (Automatic Transformation)
Use this to let FOP call an XSLT engine (like XT) to transform XML into FO before rendering. This requires including FOP, your SAX parser, and the XT library in your classpath.
java -Dorg.xml.sax.parser=com.jclark.xml.sax.Driver -cp fop_x_xx_x.jar;xt.jar;xerces.jar org.apache.fop.apps.CommandLine xml-file xsl-file pdf-file
Note: Replace com.jclark.xml.sax.Driver with your specific SAX parser class if not using XP.
3. Previewing FO files (AWT Viewer)
Use this to preview the FO file using a Swing-based viewer instead of generating a PDF.
java -cp fop_x_xx_x.jar;xerces.jar org.apache.fop.apps.AWTCommandLine fo-file
java org.apache.fop.apps.CommandLine fo-file pdf-file