Page 1 of 1

HOWTO use FOP with fixes

PostPosted: Mon Apr 22, 2013 9:37 am
by jason
FOP 1.0 and 1.1 are affected by an issue documented and partially worked around by:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                // Workaround for https://issues.apache.org/bugzilla/show ... i?id=54094
                // You can comment this out if you are using FOP post 1.1
                // (see pom.xml for tips on how to configure that)
                Object o = wordMLPackage.getMainDocumentPart().getContent().get(0);
                if (o instanceof P
                                && ((P)o).getPPr()!=null) {
                        PPr pPr = ((P)o).getPPr();
                        BooleanDefaultTrue val = new BooleanDefaultTrue();
                        val.setVal(Boolean.FALSE);
                        pPr.setPageBreakBefore(val);
                }
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


As per https://issues.apache.org/bugzilla/show ... i?id=54094 the bug was fixed after the FOP 1.1 release. At the time of writing, FOP 1.1 is the current release.

docx4j 2.8.1 can't use any recent build of FOP, since the method for configuring FOP changed after 1.1. See wiki.apache.org/xmlgraphics-fop/FopFactoryConfiguration

Current docx4j tip on GitHub can use either FOP 1.0/1.1 or a later version.

You can get a snapshot of this version of docx4j, with appropriate dependencies, including FOP built from svn, at http://www.docx4java.org/docx4j/docx4j- ... Pr1468367/

The changes are:

- replace docx4j jar
- replace fop jar
- replace xmlgraphics-commons
- replace batik jar

If you are using pom.xml, add:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                <dependency>
                        <groupId>commons-io</groupId>
                        <artifactId>commons-io</artifactId>
                        <version>1.3.1</version>
                </dependency>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


and comment out:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
     
        <dependency>
                <groupId>org.apache.xmlgraphics</groupId>
                <artifactId>xmlgraphics-commons</artifactId>
                <version>1.5</version>
        </dependency>
        <dependency>
                <groupId>org.apache.xmlgraphics</groupId>
                <artifactId>fop</artifactId>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


You'll also need to add the following classes to your class path:

http://svn.apache.org/viewvc/xmlgraphic ... ll-1.7.jar

http://svn.apache.org/viewvc/xmlgraphic ... -trunk.jar

Re: HOWTO use FOP with fixes

PostPosted: Thu Mar 20, 2014 10:38 am
by jason
To try an updated FOP with docx4j 3.0.x:

1. remove existing FOP and xml-graphics dependencies from docx4j pom (or your classpath)
2. get a FOP jar from http://ci.apache.org/projects/xmlgraphi ... snapshots/
3. add https://github.com/apache/fop/raw/trunk ... -trunk.jar
4. add https://github.com/apache/fop/raw/trunk ... -trunk.jar

That should be all you need to do..