Java PDF code FAQ

This page lists the frequently asked questions we have encountered on using our PDF library and contains links to code examples which you can use. If you have a question we do not answer here, please post on the support forums and we will answer.

General questions

Q. What PDF features are supported?

You can get a full list of the PDF Specification supported here.

Q. Where can I find some simple examples on how to use JPedal?

Our support section includes lots of very simple  examples (most around 3 lines of code) to convert PDF to Image, extract text, perform text search, access form Data, get a page count, access PDF metadata, print a PDF, etc.

Q. Does the software run on client or server?

We have customers using it on both. Viewer, ViewerFX provide viewers, PdfDecoder  provides Swing and non-Swing support and PdfDecoderServer can used on the server in headless mode or for non-GUI and non-printing functions.

Q. Can I log information to a logfile?


Q. How do I get the version number of the software?

There is a public static variable PdfDecoder.version or PdfDecoderServer.version which you can access.


View PDF files

Q. Are there some simple examples to view a PDF file?

org/jpedal/examples/baseviewer/ and org/jpedal/examples/baseviewer/ are very simple java PDF viewers with minimal functionality.
We would recommend you look our fully featured Swing PDF viewer or JavaFX PDF viewer. They are totally configurable and include lots of functionality (Search/Print/multiple views/etc). You can easily switch between them as they share the same API.

Q. How can I add a Java PDF viewer into my code in 2 lines of code?

Try this Java code (with the JPedal jar on your classpath).

Viewer viewer = new Viewer(rootContainer, null);

ViewerFX viewer = new ViewerFX(rootContainer, null);

Now the object has been set up correctly it can be added to your application like any other swing component.

Here is the simple Swing application I made, demonstrating how this can be done.

If you wish to remove some or all of the viewer user interface that is also possible by simply setting the preferences to display the desired components and passing in the path (on the file system or within the jar by adding “jar:” to the start of the path) to this file in the Viewer(Container display, String PreferencesPath) constructor.


Print PDF files

Q. Is there a complete example to print a PDF file?

org/jpedal/examples/printing/ is a full code example (with additional features) to print a PDF file.

There is also a 5 step tutorial to add printing to your code on at how-to-print-pdf-files-in-java


PDF Image questions

Q. How do I convert a PDF to Image?

The support section provides some simple APIs for fully automated PDF to image conversion.



PDF Text questions

Q. How do I select text in the PDF viewer?

There is a tutorial on  highlighting-text-in-viewer