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 JPedal (a Java library to Convert, Print, View PDF files). 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
What is JPedal?
JPedal is a commercial Java PDF Library that makes it easy for Java developers to work with PDF Documents in Java.
Why use JPedal?
JPedal makes it much easier to work with PDF files from Java. Because we have been actively developing our Java PDF Toolkit for over 20 years, it works with all those problem PDF files out there.
What licenses are available?
We have 2 licenses available:
'Server' for on premises and cloud servers and 'OEM' for use in a named end user applications. Both are one time fees with options support renewal after 12 months.
How to use JPedal?
Want to learn more about JPedal and how to use it, we have plenty of tutorials and guides to help you.