Written by James McDonald

September 8, 2024

3 years ago I got Apache FOP working with the Sourceforge version of Barcode4J:

The source forge version of Barcode4J dates from 2015 it has been forked, is now hosted on Github and is being actively developed.

So this is how I got it working from the fop cli

You need maven installed and openjdk (this is on Ubuntu 24.04 in WSL)

apt-get install maven openjdk-17-jdk openjdk-21-jdkjava

Testing it works (see below for the install script)

Copy the xsl and xml files from barcode4j-2.2.4\barcode4j-fop-ext\src\test\resources\ to fop-2.9/fop/

Now goto fop-2.9/fop/ and run a test using the samples from above

./fop -xml barcodes.xml -xsl barcode-data-XSL-2.xsl out.pdf

Here is what it looks like if it's working

You should get this sample:

Install script

This is how I got it working I just had to copy the correct jars from barcode4J into the fop/lib directory

wget -O barcode4j-2.2.4.tar.gz https://github.com/SingingBush/barcode4j/archive/refs/tags/2.2.4.tar.gz
wget -O fop-2.9-bin.tar.gz 'https://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.9-bin.tar.gz&action=download'

tar -xzvf barcode4j-2.2.4.tar.gz

cd barcode4j-2.2.4

mvn package

cd ../

tar -xzvf fop-2.9-bin.tar.gz

FOP_LIB_DIR=/home/james/fop-2.9/fop/lib/

BARCODE4J_LIBS='/home/james/barcode4j-2.2.4/barcode4j-saxon8/target/barcode4j-saxon8-2.2.4.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/avalon-framework-api-4.3.1.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/xalan-2.7.2.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/fop/fop-events-2.8.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/fop/fop-core-2.8.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/fop/batik-all-1.16.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/fop/fop-util-2.8.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/serializer-2.7.2.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/jdom2-2.0.6.1.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/avalon-framework-impl-4.3.1.jar
/home/james/barcode4j-2.2.4/barcode4j/lib/zxing-core-3.5.1.jar
/home/james/barcode4j-2.2.4/barcode4j-fop-ext/target/barcode4j-fop-ext-2.2.4.jar
/home/james/barcode4j-2.2.4/barcode4j-xalan/target/barcode4j-xalan-2.2.4.jar
/home/james/barcode4j-2.2.4/barcode4j-cli/target/lib/barcode4j-2.2.4.jar
/home/james/barcode4j-2.2.4/barcode4j-xgc/target/barcode4j-xgc-2.2.4.jar'

for i in $BARCODE4J_LIBS
do
    echo $i
    cp $i $FOP_LIB_DIR
done

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…