PDF Library Code Examples
JPedal includes a large number of example PDF applications written in Java for you to use and customise. Each one is described below along with a link to code and any related items.
Simple APIs for all common functions
If you are just looking for a simple example to quickly use a feature, we have detailed APIs for common functions (PDF2Image, text extract, text search, etc) on the main support page.
Click the button beneath to download a zip with the Java source code examples (they need the JPedal jar to work).
Please note: Viewer and Print code examples will not run on server version.
Example Source Code for JPedal
PDF to image conversion
- ConvertPagesToImages – fully automated program to rasterize PDF pages as images and optionally scale.
- ConvertPagesToHiResImages – extract PDF pages at the best possible quality. If the images are larger than the page, it scales up the page rather than scaling down the image.
- PDF to image conversion very simple example shown in the Java code FAQ – just the minimum code needed for PDF to image conversion
PDF Viewers (not server version)
- Viewer is a very comprehensive java PDF viewer in Swing which is totally configurable.
- ViewerFX is a very comprehensive java PDF viewer in JavaFX which is totally configurable.
- MultiViewer adds the ability to open multiple PDF files in separate panes to the Swing Viewer.
PDF Printing (not server version)
- SilentPrinting provides an example on how to print PDF files automatically from Java.
- Clipped Image extraction – fully automated extraction of PDF page images as tif, png or jpeg with ability to define output dimensions and image quality. Created to help a large catalogue company put images online.
- ExtractFormDataAsObject extracts raw PDF form data from a PDF file.
- ExtractImages extracts and saves images from a PDF file. Extracts the raw images so also consider Clipped Image extraction.
- ExtractStructuredContent extracts any Structured content (text with additional metatags to preserve structure).
- ExtractTextInRectangle extracts text in any rectangular area.
- ExtractTextAsWordlist will generate a list of words on the PDF page with co-ordinates.
- ExtractOutline will extract the outline tree from a PDF file if present.
PDF text Search
- FindTextInRectangle will find locations of word on the PDF page.