PDFBox - Environment


Advertisements

Installing PDFBox

Following are the steps to download Apache PDFBox −

Step 1 − Open the homepage of Apache PDFBox by clicking on the following link − https://pdfbox.apache.org/

Step 2 − The above link will direct you to the homepage as shown in the following screenshot −

PDFBox Homepage

Step 3 − Now, click on the Downloads link highlighted in the above screenshot. On clicking, you will be directed to the downloads page of PDFBox as shown in the following screenshot.

PDFBox Downloads.jpg

Step 4 − In the Downloads page, you will have links for PDFBox. Click on the respective link for the latest release. For instance, we are opting for PDFBox 2.0.1 and on clicking this, you will be directed to the required jar files as shown in the following screenshot.

PDFBox Jarfiles.jpg

Step 5 − Download the jar files pdfbox-2.0.1.jar, fontbox-2.0.1.jar, preflight-2.0.1.jar, xmpbox-2.0.1.jar and, pdfbox-tools-2.0.1.jar.

Eclipse Installation

After downloading the required jar files, you have to embed these JAR files to your Eclipse environment. You can do this by setting the Build path to these JAR files and by using pom.xml.

Setting Build Path

Following are the steps to install PDFBox in Eclipse −

Step 1 − Ensure that you have installed Eclipse in your system. If not, download and install Eclipse in your system.

Step 2 − Open Eclipse, click on File, New, and Open a new project as shown in the following screenshot.

Eclipse file menu

Step 3 − On selecting the project, you will get New Project wizard. In this wizard, select Java project and proceed by clicking Next button as shown in the following screenshot.

Eclipse Newproject wizard

Step 4 − On proceeding forward, you will be directed to the New Java Project wizard. Create a new project and click on Next as shown in the following screenshot.

Create project wizard

Step 5 − After creating a new project, right click on it; select Build Path and click on Configure Build Path… as shown in the following screenshot.

Eclipse build path

Step 6 − On clicking on the Build Path option you will be directed to the Java Build Path wizard. Select the Add External JARs as shown in the following screenshot.

Eclipse External jars

Step 7 − Select the jar files fontbox-2.0.1.jar, pdfbox-2.0.1.jar, pdfbox-tools-2.0.1.jar, preflight-2.0.1.jar, xmpbox-2.0.1.jar as shown in the following screenshot.

Jar Files location

Step 8 − On clicking the Open button in the above screenshot, those files will be added to your library as shown in the following screenshot.

Jar Files added

Step 9 − On clicking OK, you will successfully add the required JAR files to the current project and you can verify these added libraries by expanding the Referenced Libraries as shown in the following screenshot.

Eclipse Jar files

Using pom.xml

Convert the project into maven project and add the following contents to its pom.xml.

<project xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>my_project</groupId>
   <artifactId>my_project</artifactId>
   <version>0.0.1-SNAPSHOT</version>

   <build>
      <sourceDirectory>src</sourceDirectory>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
               <source>1.8</source>
               <target>1.8</target>
            </configuration> 
         </plugin>
      </plugins> 
   </build> 
   
   <dependencies>  
      <dependency> 
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>pdfbox</artifactId> 
         <version>2.0.1</version> 
      </dependency>   
   
      <dependency> 
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>fontbox</artifactId> 
         <version>2.0.0</version> 
      </dependency>
      
      <dependency>  
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>jempbox</artifactId> 
         <version>1.8.11</version> 
      </dependency> 
        
      <dependency>
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>xmpbox</artifactId> 
         <version>2.0.0</version> 
      </dependency> 
     
      <dependency> 
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>preflight</artifactId> 
         <version>2.0.0</version> 
      </dependency> 
     
      <dependency> 
         <groupId>org.apache.pdfbox</groupId> 
         <artifactId>pdfbox-tools</artifactId> 
         <version>2.0.0</version> 
      </dependency>

   </dependencies>
   
</project>
Advertisements