FOP-0.93

Introduction to FOP

The FOP (Formatting Objects Processor) package contains a print formatter driven by XSL formatting objects (XSL-FO). It is a Java application that reads a formatting object tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PCL, PostScript, SVG, XML (area tree representation), print, AWT, MIF and ASCII text. The primary output target is PDF.

Package Information

Additional Downloads

Required packages

FOP Dependencies

Required

Apache Ant-1.7.0

Optional

JIMI SDK, XMLUnit, and Forrest (only used to rebuild the documentation)

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/fop

Installation of FOP

Ensure $JAVA_HOME is set correctly before beginning the build. To build the JIMI SDK and/or XMLUnit extension classes, ensure the corresponding .jar files are identified in the CLASSPATH environment variable.

Installing OFFO Hyphenation Patterns

Before beginning the build, unpack the FOP source tarball and the hyphenation zipfile from the same directory, then change directories into the root of the FOP source tree. The XML Hyphenation patterns will be copied into the FOP source tree by running the following commands:

cp ../offo-hyphenation/hyph/* hyph &&
rm -rf ../offo-hyphenation

Installing JAI

[Tip]

Tip

The $FOP_BUILD_DIR/JAI.bin command below installs the JAI components in the JDK tree. You will be required to view, and then accept (by entering a y keypress), a license agreement before the installation will continue. If you are scripting (automating) the build, you'll need to account for this. There is information about automating build commands in the Automated Building Procedures section of Chapter 2. Towards the end of this section, specific information for automating this type of installation is discussed.

Install the JAI components by running the following commands as the root user while in the root of the FOP source tree:

install -m755 ../jai-1_1_2_01-lib-linux-i586-jdk.bin JAI.bin &&
sed -i 's/tail +122/tail -n +122/' JAI.bin &&

FOP_BUILD_DIR=$(pwd) &&
cd $JAVA_HOME &&

$FOP_BUILD_DIR/JAI.bin &&

cd $FOP_BUILD_DIR &&
rm JAI.bin

Installing FOP Components

Install FOP by running the following commands:

ant &&
ant javadocs

The unit regression tests were performed in the build step above.

Now, as the root user:

install -v -d -m755 /opt/fop-0.93 &&
cp -v -R * /opt/fop-0.93 &&
ln -v -sf fop-0.93 /opt/fop

Command Explanations

sed -i 's/tail +122/tail -n +122/' ...: The JAI binary file has a tail command imbedded in the file which uses obsolete syntax and causes the file to unpack incorrectly. This command fixes the obsolete syntax.

$FOP_BUILD_DIR/JAI.bin: This command installs the JAI components into the JDK file structure. $FOP_BUILD_DIR is used as a reference point to the source executable and as a method to return back to the FOP source tree.

ant: This reads the build.xml file and performs the default all target which builds the package and runs the unit regression tests.

ant javadocs: This builds the Java API documentation. Omit this step if desired.

ln -v -sf fop-0.93 /opt/fop: This is optional and creates a convenience symlink so that $FOP_HOME doesn't have to be changed each time there's a package version change.

Configuring FOP

Config Files

~/.foprc

Configuration Information

Using FOP to process some large FO's (including the FO derived from the BLFS XML sources), can lead to memory errors. Unless you add a parameter to the java command used in the fop script you may receive messages similar to the one shown below:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

To avoid errors like this, you need to pass an extra parameter to the java command used in the fop script. This can be accomplished by creating a ~/.foprc (which is sourced by the fop script) and adding the parameter to the FOP_OPTS environment variable.

The fop script looks for a FOP_HOME environment variable to locate the FOP class libraries. You can create this variable using the ~/.foprc file as well. Create a ~/.foprc file using the following commands:

cat > ~/.foprc << "EOF"
FOP_OPTS="-Xmx<RAM_Installed>m"
FOP_HOME="/opt/fop"

EOF

Replace <RAM_Installed> with a number representing the amount of RAM installed in your computer (in megabytes). An example would be FOP_OPTS="-Xmx768m". For more information about memory issues running FOP, see http://xml.apache.org/fop/running.html#memory.

To include the fop script in your path, update your personal or system-wide profile with the following:

PATH=$PATH:/opt/fop

Contents

Installed Programs: fop
Installed Libraries: fop.jar and numerous support library classes located in /opt/fop/{build,lib}; JAI components include libmlib_jai.so, jai_codec.jar, jai_core.jar, and mlibwrapper_jai.jar
Installed Directory: /opt/fop-0.93

Short Descriptions

fop

is a wrapper script to the java command which sets up the FOP environment and passes the required parameters.

fop.jar

contains all the FOP Java classes.

Last updated on 2008-05-10 18:53:20 -0500