Jacob Collins Jacob is a Java developer and the product manager of JPedal

How to view PDF files in Java (Tutorial)

1 min read

Java PDF viewer

If you want to view PDF files in your Java application you will quickly find that Java has no native support for the PDF file format. It is for this reason that you would need a Java PDF viewer.

Today I’m going to walk you through the steps required to use the PDF Viewer in our JPedal  Java PDF Library. Once installed you will have a Java PDF API to access all aspects of the viewer from your Java code.

How to open PDF files in Java with Maven

There are a few ways you can install JPedal, you can either download the trial JAR from our website, or you can add JPedal to your project dependencies. This will allows you to view PDF documents in Java.

In this tutorial, I am going to be using Maven however you can also use Gradle.


You can find the latest version number of JPedal on our support site.

Once you have the dependency setup, you can use the code below to view PDF in Java.

How to view the PDF files from the Command line

If you want to quickly view PDF files, you may use the JPedal Viewer. To launch the viewer you can double-click to open the JAR or you can run the following:

How to view the PDF files in an existing Java application

JPedal provides a very easy to use Java PDF API for adding a PDF Viewer to your Java code. JPedal includes a single Viewer class to open and view PDF files. Creating an instance of the JPedal Viewer only requires two lines of code:


You can then use the following to open and display a PDF file:

How to customise your Java PDF Viewer

You may want to customise the look and feel of the PDF view, for example you might not want customers to be able to print your PDFs, or you might want to hide the menu buttons.

All of this and more is possible using a properties profile:

  • Create an XML properties file by exporting and modifying the default one. In JPedal go to Edit -> Preferences and click Save As.
  • Customise the properties file to your requirements. For example:
  • Create a viewer and load the properties file using

Learn more

Visit www.idrsolutions.com/jpedal to learn more about JPedal.

Visit support.idrsolutions.com/jpedal for comprehensive documentation and tutorials.



The JPedal PDF library allows you to solve these problems in Java


Why do developers choose JPedal over alternatives?

  1. Actively developed commercial library with full support and no third party dependencies.
  2. Simple licensing options and source code access for OEM users.
  3. Process PDF files up to 3x faster than alternative Java PDF libraries.

Jacob Collins Jacob is a Java developer and the product manager of JPedal