Running on Java 17 or later
JPedal includes a simple API. JPedal is written in Java but can be used from other languages or command line.
How to use JPedal from Command Line or any language
JPedal takes a set of commands which allow easy access to JPedal features. This list will appear if no commands are run or if you use the --help
command as follows.
java -jar jpedal.jar --help
JPedal - Java PDF Library - <Version>
Features:
PDF Viewer
PDF Inspector
Convert Pages to Images
Extract Text
Extract Embedded Images
Extract Metadata
Print PDF
Homepage: https://www.idrsolutions.com/jpedal
Javadoc: https://files.idrsolutions.com/maven/site/jpedal/apidocs/
Available Commands:
--view inputFile.pdf [pageNumber]
--convert inputFolder outputFolder [outputFormat] [scalingAsFloat] [pageRange]
--help
--print inputFile.pdf printerName [pageNumber]
--extractImages inputFile.pdf outputFolder outputFormat
--extractClippedImages inputFile.pdf outputFolder outputFormat (outputHeight subDirectory)...
--metadata inputFile.pdf [typeOfData]...
--inspect inputFile.pdf
--copyoutline inputFile.pdf outputFile.pdf
Examples to Convert PDF to Image
# Convert Single file to BMP file (separate BMP for each page)
java -jar jpedal.jar --convert "inputFile.pdf" imageOutput BMP
# Convert directory of files to PNG file (separate PNG for each page)
java -jar jpedal.jar --convert files imageOutput PNG
More details can be found in the convert PDF to Image tutorials.
Examples to View PDF File
# Open inputFile.pdf in PDF Viewer
java -jar jpedal.jar --view "inputFile.pdf"
# Open new blank PDF Viewer window
java -jar jpedal.jar --view
More details can be found in the viewer tutorial.
Examples to Print PDF File
# Print the specified pdf file on the specified printer
java -jar jpedal.jar --print "inputFile.pdf" "printerName"
# Print page 1 of the pdf file on the specified printer
java -jar jpedal.jar --print "inputFile.pdf" "printerName" 1
More details can be found in the print tutorial.
Examples to Extract Images from PDF File
# Extract all raw images as PNG files from the specified PDF file
java -jar jpedal.jar --extractImages "inputFile.pdf" "outputFolder" PNG
More details can be found in the extract images tutorial.
Examples to Extract Clipped Images from PDF File
# Extract all clipped images as PNG files from the specified PDF file
# at original size
java -jar jpedal.jar --extractClippedImages "inputFile.pdf" "outputFolder" PNG -1 raw
# Extract all clipped images as PNG files from the specified PDF file
# at original size, and a height of 200px
java -jar jpedal.jar --extractClippedImages "inputFile.pdf" "outputFolder" PNG -1 "raw" 200 "height200"
More details can be found in the extract clipped images tutorial.
Examples to Extract Metadata from PDF File
# Extract all types of metadata from the specified file as JSON
java -jar jpedal.jar --metadata "inputFile.pdf"
# Extract only fields metadata from the specified file as JSON
java -jar jpedal.jar --metadata "inputFile.pdf" fields
More details and a full list of metadata that can be returned can be found in the metadata tutorial.