FOP-0.20.5

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

Choose the “Linux JDK Install” file after accepting the license agreement.

FOP dependencies

Required

J2SDK-1.4.2

Optional

libxslt-1.1.12, JIMI SDK, Batik and Forrest (only used to rebuild the documentation)

Installation of FOP

[Note]

Note

Ensure $JAVA_HOME is set correctly before beginning the build. Additionally, the build will fail if your version of the JDK is higher than 1.4.2_x.

Some versions of tar will display a message similar to “tar: A lone zero block at 33476” when unpacking the source tarball. You may safely ignore this message.

Installing JAI

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

chmod 755 ../jai-1_1_2_01-lib-linux-i586-jdk.bin &&
FOP_BUILD_DIR=$(pwd) &&
cd $JAVA_HOME &&
yes | $FOP_BUILD_DIR/../jai-1_1_2_01-lib-linux-i586-jdk.bin &&
cd $FOP_BUILD_DIR

Installing FOP required components

Install FOP by running the following commands:

./build.sh &&
sed -i -e "s/build/lib/" fop.sh

Now, as the root user:

install -v -d -m755 \
    /opt/fop-0.20.5/{bin,lib,docs/{general,lib,site}} &&
install -v -m755 fop.sh /opt/fop-0.20.5/bin &&
install -v -m644 build/fop.jar lib/avalon-framework-cvs-20020806.jar \
    /opt/fop-0.20.5/lib &&
install -v -m644 docs/* /opt/fop-0.20.5/docs &&
install -v -m644 CHANGES LICENSE README ReleaseNotes.html STATUS \
    /opt/fop-0.20.5/docs/general &&
install -v -m644 lib/{avalon.LICENSE.txt,readme} \
    /opt/fop-0.20.5/docs/lib &&
cp -v -R build/site/* /opt/fop-0.20.5/docs/site &&
ln -svf fop-0.20.5 /opt/fop

Installing the Batik JAR

You'll need to install one additional Java class library to process SVG objects. This library is part of the Batik package, but is also included with the FOP package. If you have Batik installed, ensure the batik.jar library is included in your $CLASSPATH environment variable. Alternatively, create a symbolic link from /opt/fop-0.20.5/lib/batik.jar pointing to the full path of the installed batik.jar file so that the fop.sh script will automatically pick it up.

If you don't have the Batik package installed, run the following commands as the root user:

install -v -m644 lib/batik.jar /opt/fop-0.20.5/lib &&
install -v -m644 lib/batik.LICENSE.txt \
    /opt/fop-0.20.5/docs/lib

Installing the Xalan-Java components

The components of FOP required to process FO files created by an XSL transformation engine (also known as an XSLT processor) is now complete. An XSL transformation engine (xsltproc) is included with the libxslt-1.1.12 package in BLFS. The FOP package includes components of Xalan-Java to accomplish XSL transformations. If you have the Xalan-Java package installed, skip to the next section.

If you wish to install the Xalan-Java components provided by the FOP package, run the following commands as the root user:

sed -i -e "s/build/lib/" xalan.sh &&
install -v -m755 xalan.sh /opt/fop-0.20.5/bin &&
install -v -m644 lib/xml-apis.jar \
                 lib/xercesImpl-2.2.1.jar \
                 lib/xalan-2.4.1.jar \
    /opt/fop-0.20.5/lib &&
install -v -m644 lib/{xml-apis,xerces,xalan}.LICENSE.txt \
                 lib/xml-apis.README.txt \
    /opt/fop-0.20.5/docs/lib

Installing the Jimi SDK JAR

If you installed the Java Image I/O class library (Jimi SDK) into the FOP source tree lib directory before building FOP (this will enable Jimi support), ensure you also install this JAR file into /opt/fop-0.20.5/lib.

Command explanations

yes | $FOP_BUILD_DIR/../jai-...-jdk.bin: This command installs the JAI components into the JDK file structure. The yes command is piped through so that you don't have to scroll through four pages of the license agreement and automatically responds “yes” to the agreement. $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.

sed -i -e "s/build/lib/" ...: These commands modify the installed shell scripts so that the location of the installed fop.jar file is correctly identified.

install -v ...; cp -v ...: There is no installation script provided by the FOP package. These commands install the package.

ln -svf fop-0.20.5 /opt/fop: This 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.sh 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.sh script. This can be accomplished by creating a ~/.foprc (which is sourced by the fop.sh script) and adding the parameter to the FOP_OPTS environment variable.

The fop.sh 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. 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.sh script in your path, update your personal or system-wide profile with the following:

PATH=$PATH:/opt/fop/bin

Contents

Installed Programs: fop.sh and xalan.sh
Installed Libraries: avalon-framework-cvs-20020806.jar, batik.jar, fop.jar, xalan-2.4.1.jar, xercesImpl-2.2.1.jar and xml-apis.jar. JAI components include libmlib_jai.so, jai_codec.jar, jai_core.jar and mlibwrapper_jai.jar
Installed Directory: /opt/fop-0.20.5

Short Descriptions

fop.sh

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 2005-02-16 14:46:41 -0700