Link

How to setup in Eclipse

JPedal is a Java PDF library that provides functionality to view, print, rasterize and extract content from PDF files in their own Java Applications. Whilst the library has a multitude of classes to access these features, you will likely want to add the functionality to your own system or maybe expand on what is provided. This can be done with an IDE such as Eclipse.

This tutorial will show you how to set up a project and start using JPedal in Eclipse using a sample JPedal project.

Please note: A trial or full copy of the JPedal jar is needed. You can download the trial jar from here.

Step 1 - Download and install Eclipse:

If you haven’t already, download the latest copy of Eclipse. 1

Step 2 - Clone the repository:

Go to the GitHub repository of our example and click on ‘Code’. 2

Either:

Or

  • Click ‘Download ZIP’ and extract zip to a path of your choice.

In the new project location, create a ‘lib’ directory, which will be used to store dependencies.

Step 3 - Create a project:

Open up Eclipse, click ‘File’ -> ‘New’ -> ‘Java Project’. Add a project name. Untick ‘Use default location’ and use ‘Browse’ to find the location of the cloned repository. Click ‘Finish’. 3

Step 4 - Add JPedal dependency (trial or full version):

Now you have a project, find your copy of the JPedal jar file, add it to the ‘lib’ directory.

Right-click on your project and go to ‘Properties’. Then go to ‘Java Build Path’ -> ‘Libraries’. 4

Click on ‘Add JARs…’, go to the lib folder, select the JPedal jar, click ‘Ok’, then ‘Apply and Close’.

5

Step 5 - Start coding:

public static void main(String[] args) {
    try {
        pdfToImage();
//        pdfViewer();
//        extractWords();
//        extractImages();
    } catch (final Exception e) {
        e.printStackTrace();
    }
}

Change the parameters of the action to point to the correct input/output

public static void pdfToImage() throws PdfException {
    ConvertPagesToImages.writeAllPagesAsImagesToDir("/path/to/input/file.pdf",
            "/path/to/output/", "png", 1.33f);
}

Click the run button.

Want to add more to your project?

Check out the following tutorials for more information to see what JPedal can do for you: