fop-2.3

#### Beyond Linux® From Scratch - Version 2019-02-27

### Chapter 50. PostScript

- Prev

  ePDFView-0.1.8

- Next

  MuPDF-1.14.0

- Up
- Home

# fop-2.3

## 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.

This package is known to build and work properly using an LFS-8.4 platform.

### Package Information

- Download (HTTP): https://archive.apache.org/dist/xmlgraphics/fop/source/fop-2.3-src.tar.gz

- Download MD5 sum: fc95040a8db4a7f22c6f26e18fd6d033

- Download size: 26 MB

- Estimated disk space required: 497 MB

- Estimated build time: 1.1 SBU

### Additional Downloads

Required Additional Downloads:

- PDFBox:
  http://mirror.reverse.net/pub/apache/pdfbox/2.0.13/pdfbox-2.0.13.jar
  91d98c9a48cb6e89a3a1eeb4294f2665
  2.4 MB

- PDFBox Fonts:
  http://mirror.reverse.net/pub/apache/pdfbox/2.0.13/fontbox-2.0.13.jar
  f6dd2dbe55ea47062f7ac0543f7e29c6
  1.5 MB

Recommended packages

- Objects for Formatting Objects (OFFO) hyphenation patterns:
  https://downloads.sourceforge.net/offo/2.2/offo-hyphenation.zip
  bf9c09bf05108ef9661b8f08d91c2336
  862 KB

### fop Dependencies

#### Required

apache-ant-1.10.5

#### Optional

X Window System (to run tests), JAI Image I/O Tools, and JEuclid

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 can be found via the `CLASSPATH` environment variable.

### Installing OFFO Hyphenation Patterns

Copy the XML hyphenation patterns into the fop source tree by running the following commands:

    unzip ../offo-hyphenation.zip &&
    cp offo-hyphenation/hyph/* fop/hyph &&
    rm -rf offo-hyphenation

### Installing fop Components

The javadoc command that ships with OpenJDK 10 has become much more strict than previous versions regarding conformance of the Javadoc comments in source code to HTML. The FOP documentation does not meet those standards, so the conformance checks have to be disabled. This can be done with the following command:

    sed -i '\@</javad@i\
    <arg value="-Xdoclint:none"/>\
    <arg value="--allow-script-in-comments"/>\
    <arg value="--ignore-source-errors"/>' \
        fop/build.xml

The stack size set in `build.xml` for building the hyphenation patterns is not large enough. Change it by running:

    sed -e '/hyph\.stack/s/512k/1M/' \
        -i fop/build.xml

The `build.xml` file calls for an old version of PDFBox components that are no longer available. Copy the updated PDFBox components into the source tree:

    cp ../{pdf,font}box-2.0.13.jar fop/lib

Compile fop by running the following commands:

    cd fop                    &&
    export LC_ALL=en_US.UTF-8 &&
    ant all javadocs          &&
    mv build/javadocs .

The junit test suite was run as part of the above commands.

Now, install Fop as the `root` user:

    install -v -d -m755 -o root -g root          /opt/fop-2.3 &&
    cp -vR build conf examples fop* javadocs lib /opt/fop-2.3 &&
    chmod a+x /opt/fop-2.3/fop                                &&
    ln -v -sfn fop-2.3 /opt/fop

## Command Explanations

sed -i ... build.xml: This adds two switches to the javadoc command, preventing some errors to occur when building the documentation.

export LC_ALL=en_US.UTF-8: the compiler fails if using an ASCII locale.

ant `target`: This reads the file `build.xml` and builds the target: `compile` compiles the java sources, `jar-main` generates jar archives, `jar-hyphenation` generates the hyphenation patterns for FOP, `junit` runs the junit tests, and `javadocs` builds the documentation. The `all` target runs all of the above.

ln -v -sf fop-2.3 /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"`.

To include the fop script in your path, update the system-wide profile with the following command as the `root` user:

    cat > /etc/profile.d/fop.sh << "EOF"
    # Begin /etc/profile.d/fop.sh

    pathappend /opt/fop

    # End /etc/profile.d/fop.sh
    EOF

### Note

Running fop can be somewhat verbose. The default logging level can be changed from INFO to any of FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, ALL, or OFF. To do this, edit `$JAVA_HOME/jre/lib/logging.properties` and change the entries for `.level` and `java.util.logging.ConsoleHandler.level` to the desired value.

## 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-2.3

### 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 2019-02-18 01:33:36 -0600

- Prev

  ePDFView-0.1.8

- Next

  MuPDF-1.14.0

- Up
- Home