How to setup in NetBeans
JPedal is a Java PDF library that allows developers to view, print, rasterize, extract content from, and edit PDF files in their own Java applications.
This tutorial will show you how to set up a project and start using JPedal in NetBeans.
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 NetBeans:
If you haven’t already, go to NetBeans website and download the latest version of NetBeans:
Step 2 - Create a project:
Once installed, open up NetBeans. Go to ‘New project’ then create a Java application with Ant. (This will give you all the basics you need and is great for when starting out with JPedal) Click ‘Next’ and name your project, then click ‘Finish’.

Create a ‘lib’ directory in the project to store dependencies.
Step 3 - 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 ‘Libraries’, click the plus symbol and ‘Add JAR/Folder’.

Now go to the lib folder where the JPedal jar is, click on the jar, click ‘Open’, then click ‘OK’.
Step 4 - Start coding:
Create a new class called JPedalExamples in the project’s src folder and paste in the following code:
import org.jpedal.examples.images.ConvertPagesToImages;
import org.jpedal.examples.images.ExtractImages;
import org.jpedal.examples.text.ExtractTextInRectangle;
import org.jpedal.examples.viewer.Viewer;
import org.jpedal.examples.viewer.ViewerCommands;
import org.jpedal.exception.PdfException;
public class JPedalExamples {
public static void main(String[] args) {
try {
pdfToImage();
// pdfViewer();
// extractText();
// extractImages();
} catch (final PdfException e) {
e.printStackTrace();
}
}
public static void pdfToImage() throws PdfException {
ConvertPagesToImages.writeAllPagesAsImagesToDir("inputFile.pdf", "outputFolder", "png", 1.33f);
}
public static void pdfViewer() {
final Viewer viewer = new Viewer();
viewer.setupViewer();
viewer.executeCommand(ViewerCommands.OPENFILE, "inputFile.pdf");
}
public static void extractText() throws PdfException {
ExtractTextInRectangle.writeAllTextToDir("inputFile.pdf", null, "outputFolder", -1,
ExtractTextInRectangle.OUTPUT_FORMAT.TXT, false);
}
public static void extractImages() throws PdfException {
ExtractImages.writeAllImagesToDir("inputFile.pdf", "outputFolder", "png", true, false);
}
}
Change inputFile.pdf and outputFolder to the full paths of your input file and output directory, then uncomment the method you would like to run in main.
Right-click on JPedalExamples.java and select ‘Run File’.
Want to add more to your project?
Check out the following tutorials for more information to see what JPedal can do for you:
- Convert PDF to an Image
- View PDF in Java
- Print PDF from Java
- Search the Text in PDF
- Extract Text from PDF
- Extract Images from PDF
- Extract Metadata from PDF
- Edit PDF Form Annotations