Use Java PDFTools (jpdftools.jar) Command Line to manipulate PDF files on Windows, Mac and Linux systems
Java PDFTools (jpdftools.jar) Command Line comes with a series of command line utilities. They are available as standard Java applications, you can use these PDF Tools to process your PDF files on Windows, Mac and Linux systems easily.
Java PDFTools (jpdftools.jar) Command Line Home Page:
https://veryutils.com/java-pdftools
Java PDFTools (jpdftools.jar) Command Line Tools:
Decrypt
Encrypt
ExtractText
OverlayPDF
PDFDebugger
PDFMerger
PDFSplit
PDFToImage
PrintPDF
TextToPDF
WriteDecodedDoc
Decrypt
This application will decrypt a PDF document.
NOTE: You must have the owner password to decrypt the document!
usage: java -jar jpdftools.jar Decrypt [OPTIONS] <inputfile> [outputfile]
Command Line Parameters:
-password: Password to the PDF or certificate in keystore.
-keyStore: Path to keystore that holds certificate to decrypt the document. This is only required if the document is encrypted with a certificate, otherwise only the password is required.
-alias: The alias to the certificate in the keystore.
inputfile: The PDF file to decrypt.
outputfile: The file to save the decrypted document to. If left blank then it will be the same as the input file.
Encrypt
This application will encrypt a PDF document.
usage: java -jar jpdftools.jar Encrypt [OPTIONS] <password> <inputfile>
Command Line Parameters:
-O: The owner password to the PDF, ignored if -certFile is specified.
-U: The user password to the PDF, ignored if -certFile is specified.
-certFile: Path to X.509 cert file.
-canAssemble: Set the assemble permission. Default: true
-canExtractContent: Set the extraction permission. Default: true
-canExtractForAccessibility: Set the extraction permission. Default: true
-canFillInForm: Set the fill in form permission. Default: true
-canModify: Set the modify permission. Default: true
-canModifyAnnotations: Set the modify annotations permission. Default: true
-canPrint: Set the print permission. Default: true
-canPrintDegraded: Set the print degraded permission. Default: true
-keyLength: 40, 128 or 256. The number of bits for the encryption key. For 128 and above bits Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files must be installed.
inputfile: The PDF file to encrypt.
outputfile: The file to save the encrypted document to. If left blank then it will be the same as the input file.
ExtractImages
This application will extract all images from the given PDF document.
Usage: java -jar jpdftools.jar ExtractImages [OPTIONS] <inputfile>
Command-Line Parameters:
-password: The password to the PDF document.
-prefix: Image prefix to use. Default: PDF name
-directJPEG: Forces the direct extraction of JPEG images regardless of colorspace. Default: false
ExtractText
This application will extract all text from the given PDF document.
usage: java -jar jpdftools.jar ExtractText [OPTIONS] <inputfile> [Text file]
Command Line Parameters:
-alwaysNext: Process next page (if applicable) despite IOException (ignored when -html). Default: false
-password: The password to the PDF document.
-encoding: The encoding type of the text file, e.g. ISO-8859-1, UTF-8, UTF-16BE.
-console: Send text to console instead of file. Default: false
-html: Output in HTML format instead of raw text. Default: false
-sort: Sort the text before writing. Default: false
-ignoreBeads: Disables the separation by beads. Default: false
-debug: Enables debug output about the time consumption of every stage. Default: false
-force: Enables software to ignore corrupt objects. Default: false
-rotationMagic: Analyze each page for rotated/skewed text, rotate to 0° and extract separately (slower, and ignored when -html). Default: false
-startPage: The first page to extract, one based. Default: 1
-endPage: The last page to extract, one based. Default: LastPage
OverlayPDF
This application will overlay one document with the content of another document
usage: java -jar jpdftools.jar OverlayPDF <input.pdf> [OPTIONS] <output.pdf>
Command Line Parameters:
inputfile: The PDF file to be overlayed.
defaultOverlay.pdf: Default overlay file.
-odd oddPageOverlay.pdf: Overlay file used for odd pages.
-even evenPageOverlay.pdf: Overlay file used for even pages.
-first firstPageOverlay.pdf: Overlay file used for the first page.
-last lastPageOverlay.pdf: Overlay file used for the last pages.
-page pageNumber specificPageOverlay.pdf: Overlay file used for the given page number, may occur more than once.
-position: Where to put the overlay, foreground or background. Default: background
outputfile: The resulting pdf file.
Command Line Examples:
OverlayPDF input.pdf overlay.pdf output.pdf
OverlayPDF input.pdf defaultOverlay.pdf -page 10 overlayForPage10.pdf -position foreground output.pdf
OverlayPDF input.pdf -odd oddOverlay.pdf -even evenOverlay.pdf output.pdf
PDFDebugger
This application will take an existing PDF document and allows to analyze and inspect the internal structure.
usage: java -jar jpdftools.jar PDFDebugger [inputfile]
Command Line Parameters:
-password: The password to the PDF document.
-viewstructure: Activates the "view structure" view on startup.
inputfile: the name of an optional PDF file to open.
PDFMerger
This application will take a list of pdf documents and merge them, saving the result in a new document.
usage: java -jar jpdftools.jar PDFMerger <Source PDF files (2 ..n)> <Target PDF file>
PDFSplit
This application will take an existing PDF document and split it into a number of other documents.
usage: java -jar jpdftools.jar PDFSplit [OPTIONS] <PDF file>
Command Line Parameters:
-password: The password to the PDF document.
-split: Number of pages of every splitted part of the pdf.
-startPage: The page to start at.
-endPage: The page to stop at.
-outputPrefix: The prefix for the generated file name. The resulting name will be in the format <prefix>-<nr>.pdf
Command Line Examples:
PDFSplit -split 2 sample_with_13_pages.pdf will split the pdf in pieces of 2 pages each except the last which will contain 1 page only.
PDFSplit -startPage 5 sample_with_13_pages.pdf will provide a pdf containing all pages of the source pdf starting at page 5
PDFSplit -startPage 5 -endPage 10 sample_with_13_pages.pdf will provide a pdf containing all pages from 5 to 10 of the source pdf
PDFSplit -split 2 -startPage 5 -endPage 10 sample_with_13_pages.pdf will provide 3 pdfs containing all pages from 5 to 10 of the source pdf 2 pages each
PDFToImage
This application will create an image for every page in the PDF document.
usage: java -jar jpdftools.jar PDFToImage [OPTIONS] <PDF file>
Command Line Parameters:
-password: The password to the PDF document.
-imageType: The image type to write to. Currently only jpg or png. Default: jpg
-outputPrefix: The prefix to the image file. Default: Name of PDF document
-startPage: The first page to convert, one based. Default: 1
-endPage: The last page to convert, one based. Default: LastPage
-page: The only page to extract (1-based).
-dpi: DPI resolution of exported images. Default: detected from screen (or 96 if headless)
-color: The color depth (valid: bilevel, gray, rgb, rgba). Default: rgb
-cropbox <int> <int> <int> <int>: The page area to export.
-time: Prints timing information to stdout.
PrintPDF
This application will send a pdf document to the printer.
usage: java -jar jpdftools.jar PrintPDF [OPTIONS] <inputfile>
Command Line Parameters:
-password: The password to decrypt the PDF.
-silentPrint: Print the PDF without prompting for a printer.
-printerName <name>: Print to specified printer.
-orientation [auto | portrait | landscape]: Print using orientation. Default: auto
-border: Print with border.
-dpi: Render into intermediate image with specific dpi and then print.
inputfile: The PDF file to print.
TextToPDF
This application will create a PDF document from a text file.
usage: java -jar jpdftools.jar TextToPDF [OPTIONS] <outputfile> <textfile>
Command Line Parameters:
-standardFont: The font to use for the text. Either this or -ttf should be specified but not both. Default: Helvetica
-ttf: The TTF font to use for the text. Either this or -standardFont should be specified but not both.
-fontSize: The size of the font to use. Default: 10
The following font names can be used for the parameter standardFont:
Courier
Courier-Bold
Courier-Oblique
Courier-BoldOblique
Helvetica
Helvetica-Bold
Helvetica-Oblique
Helvetica-BoldOblique
Symbol
Times-Bold
Times-Roman
Times-Italic
Times-BoldItalic
ZapfDingbats
WriteDecodedDoc
An application to decompress PDF documents.
usage: java -jar jpdftools.jar WriteDecodedDoc <input-file> <output-file>
Command Line Parameters:
-password: The password to the PDF document.
input-file: The PDF file to decompress
output-file: The destination PDF file