View and Display PDF Files in Java
JPedal is a pure Java PDF library that includes a fully featured Java PDF viewer, embeddable directly into any Java application, with single and multipage display, text search, navigation, annotations, accessibility options, and a programmable API. It can be added to an existing application in 3 lines of code.
Requirements
| Requirement | Value |
|---|---|
| Minimum Java version | Java 17 |
| Third-party dependencies | None |
Getting Started
The tutorials below cover opening PDF files in the viewer, embedding the viewer into an existing application, and accessing viewer features from code.
Viewing PDFs in the PDF Viewer
Adding the PDF Viewer to your application
Using PDF Viewer features
Customization
JPedal’s viewer UI is fully customizable. Toolbar buttons, menus, and panels can be shown, hidden, or replaced, and the viewer supports multiple languages.
Customizing the PDF Viewer UI options
Adding additional languages to JPedal Viewer
PDF Viewer properties for accessibility
Replacing the PDF Viewers notification windows
Add custom actions to the PDF Viewer
Code Interaction
The viewer exposes a command API so your application can control it programmatically. Select text highlights, draw overlays, and trigger navigation without user interaction.
Selecting and Removing Text Highlights
Drawing additional objects to the PDF page
Modes
JPedal’s viewer supports specialised display modes for PDF Portfolio files and includes a PDF inspector for debugging PDF internals.
Viewing PDF Portfolio files
Using the PDF inspection tools
Frequently Asked Questions
How do I add a PDF viewer to a Java application?
JPedal’s viewer can be embedded in 3 lines of code:
Viewer viewer = new Viewer();
viewer.setupViewer();
viewer.executeCommand(ViewerCommands.OPENFILE, "path/to/file.pdf");
Full integration instructions are in Adding the PDF Viewer to your application.
What features does the JPedal Java PDF viewer include?
The viewer supports single and multipage display, text search, navigation, annotations, form interaction (AcroForms and XFA), zoom, print, and accessibility options, with a customisable UI and programmable API.
Can the viewer be embedded in a Swing or JavaFX application?
Yes. JPedal’s viewer is a 100% Java Swing component and can be embedded into any Swing application. It can also be used within a JavaFX application via a Swing interop wrapper.
Can I control the viewer programmatically from my code?
Yes. The viewer exposes a command API via executeCommand() using the ViewerCommands constants. This allows your application to open files, navigate pages, trigger search, and control display options without user interaction.
Can I customise the viewer’s appearance and UI?
Yes. Toolbar buttons, menu items, and UI panels can be shown, hidden, or replaced. The look and feel follows the host application’s L&F settings.
Does the JPedal viewer support accessibility?
Yes. JPedal includes accessibility properties for high-contrast display, screen reader support, and keyboard navigation. See PDF Viewer properties for accessibility for configuration options.
Can the viewer display PDF Portfolio files?
Yes. JPedal supports PDF Portfolio (also known as PDF Package) files, which contain multiple embedded documents within a single PDF container.
Does the viewer support multiple languages?
Yes. The viewer UI can be localised by providing a properties file for the target language. See Adding additional languages to JPedal Viewer.
Can JPedal open password-protected PDF files in the viewer?
Yes. Pass the password programmatically via the viewer API before or during the open command.
Does JPedal require any third-party libraries for PDF viewing?
JPedal is a 100% Java solution with no third-party dependencies, no native binaries and no external tools required.
What Java version is required?
JPedal requires Java 17 as a minimum. Details at Which Java versions does JPedal support?
Can I use the PDF inspector to debug PDF files?
Yes. JPedal includes a PDF inspector that exposes the internal COS tree, object dictionaries, decoded and raw stream data, and single-step debugging. See Using the PDF inspection tools.