These components are needed during runtime, development and testing dependent on the details below.
The three PDFBox components are named pdfbox
, fontbox
and xmpbox
. The Maven groupId of all PDFBox components is org.apache.pdfbox.
PDFBox has the following basic dependencies:
Commons Logging is a generic wrapper around different logging frameworks, so you'll either need to also use a logging library like log4j or let commons-logging fall back to the standard java.util.logging API included in the Java platform.
For PDFBox Preflight tests only commons-io 2.4 is needed.
For font handling the fontbox component is needed.
To support XMP metadata the xmpbox component is needed.
To add the pdfbox, fontbox, xmpbox and commons-logging jars to your application, the easiest thing is to declare the Maven dependency shown below. This gives you the main pdfbox library directly and the other required jars as transitive dependencies.
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>...</version>
</dependency>
Set the version field to the latest stable PDFBox version.
PDFBox does not ship with all features enabled. Third party components are necessary to get full support for certain functionality.
PDF supports embedded image files, however support for some formats require third party libraries which are distributed under terms incompatible with the Apache 2.0 license:
These libraries are optional and will be loaded if present on the classpath, otherwise support for these image formats will be disabled and a warning will be logged when an unsupported image is encountered.
Maven dependencies for these components can be found in parent/pom.xml. Change the scope of the components if needed. Please make sure that any third party licenses are suitable for your project.
To include the JBIG2 library the following part can be included in your project pom.xml:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>jbig2-imageio</artifactId>
<version>...</version>
</dependency>
To include the JAI capabilities the following part can be included in your project pom.xml:
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-core</artifactId>
<version>...</version>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-jpeg2000</artifactId>
<version>...</version>
</dependency>
For more reliable JPEG decoding the following part from the TwelveMonkeys library can be included in your project pom.xml:
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-jpeg</artifactId>
<version>...</version>
</dependency>
Encrypting and sigining PDFs requires the bcprov, bcmail and bcpkix libraries from the Legion of the Bouncy Castle. These can be included in your Maven project using the following dependencies:
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15to18</artifactId>
<version>1.75</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15to18</artifactId>
<version>1.75</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15to18</artifactId>
<version>1.75</version>
</dependency>
It is always a good idea to check for a newer version of Bouncy Castle. If you are using a more recent java version you might adapt the artifactId as well.