Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can use Apache PDFBox from a terminal without writing Java: download its standalone application JAR, install Java 8 or newer, and run commands with java -jar pdfbox-app-3.0.8.jar. PDFBox 3.0.8 is the 3.0.x feature release listed on the Apache PDFBox download page; its command-line interface differs from older 2.0 examples.

What you need to run PDFBox commands

PDFBox command-line utilities are Java applications included in the standalone PDFBox application distribution. You do not need to create a Java project or write Java code, but you do need a Java runtime. PDFBox 3.0 requires Java 8 or newer, according to the PDFBox 3.0 migration guide.

  1. Download pdfbox-app-3.0.8.jar from the Apache PDFBox download page. Apache also provides signatures and checksum files there; use them if you need to verify the download.
  2. Install a Java 8-or-newer runtime if one is not already available. Confirm Java is on your PATH by running java -version.
  3. Open a terminal in the folder containing the JAR and run a command in this form: java -jar pdfbox-app-3.0.8.jar <command> [options].

For example, check the application version and available command options with java -jar pdfbox-app-3.0.8.jar -V and java -jar pdfbox-app-3.0.8.jar -h. Use the help output for the installed version before building a script around options.

Using the dependency classpath instead

If you obtained the tools with separate dependencies rather than the standalone JAR, the Apache dependencies guide shows this classpath form on Unix-like systems: java -cp "pdfbox-app-3.0.8.jar:./lib/*" org.apache.pdfbox.tools.PDFBox args. On Windows, use a semicolon instead of a colon between classpath entries: java -cp "pdfbox-app-3.0.8.jar;./lib/*" org.apache.pdfbox.tools.PDFBox args. The Maven artifact org.apache.pdfbox:pdfbox-tools is another distribution path.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PDFBox 3 command syntax differs from older examples

The PDFBox 3.0 command-line interface was rewritten, as documented in the migration guide. Use the 3.0 command names and option forms below; a tutorial written for PDFBox 2.0 may not work unchanged. The examples use the 3.0.8 standalone JAR and run from the directory containing it.

Extract text, images, metadata, and form data

Extract text from a PDF

Run java -jar pdfbox-app-3.0.8.jar export:text -i=input.pdf -o=output.txt to write extracted text to a file. To print the text in the terminal, use -console instead of an output file: java -jar pdfbox-app-3.0.8.jar export:text -i=input.pdf -console.

The command accepts options for encoding, page ranges, sorting, and output format. For example, limit extraction to pages 2 through 4 and sort text positions with java -jar pdfbox-app-3.0.8.jar export:text -i=input.pdf -o=excerpt.txt -startPage=2 -endPage=4 -sort. Use -html for HTML output or -md for Markdown output; Markdown support was added in PDFBox 3.0.4. If text appears in an unexpected reading order, try -sort or -rotationMagic and compare the results. Extracted text reflects a PDF’s text content and layout; it is not necessarily a faithful reconstruction of the page design.

Extract embedded images

Use java -jar pdfbox-app-3.0.8.jar export:images -i=input.pdf to extract images stored in the PDF. The command has options for output prefixes, color conversion, passwords, and direct JPEG or JPX extraction. Check java -jar pdfbox-app-3.0.8.jar export:images -h for the exact options available in your installed release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Export metadata and form data

Use export:xmp to write XMP metadata to a file or the console, optionally targeting a page. Use export:fdf or export:xfdf to export AcroForm data. These commands export PDF content or data; they do not convert a PDF into a complete editable document.

Render PDF pages as PNG or JPEG images

The render command creates an image for each selected PDF page. Specify an output format such as PNG or JPG, resolution, page range, color mode, crop box, output prefix, and—where supported—quality and subsampling options.

For example, render pages 1 through 3 as PNG files at 150 DPI with an output prefix: java -jar pdfbox-app-3.0.8.jar render -i=input.pdf -format=PNG -dpi=150 -startPage=1 -endPage=3 -prefix=page. Check the command help if an option spelling differs in your installed release: java -jar pdfbox-app-3.0.8.jar render -h.

  • Higher DPI generally creates larger images and can preserve more detail, at the cost of storage and processing time.
  • PNG is useful when you want lossless output; JPEG is often smaller for photographic pages but uses lossy compression.
  • Choose color mode, crop settings, and quality deliberately. Test representative pages before rendering a large batch.

Merge content, create PDFs, or fill forms

Overlay one PDF on another

Use overlay to place pages from one PDF over another. The command includes controls for foreground or background placement, first or last page, even or odd pages, page-specific overlays, rotation adjustment, and reusing all overlay pages. Because overlay behavior depends on page matching and options, test a short copy before applying it to a full document.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a PDF from text or images

fromtext creates a PDF from a text file. Its options control page size, margins, font, character set, line spacing, and orientation. fromimage creates a PDF from image files, with options for page sizing, resizing, and automatic orientation. Use the command-specific help to choose settings that suit the source files.

Import form data

Use import:fdf or import:xfdf to place FDF or XFDF form data into a PDF. Preserve an untouched copy of the form before importing, especially when processing documents in batches.

Encrypt or decrypt a PDF

Encrypt a PDF

The encrypt command can apply password-based or certificate-based encryption. Its documented options include 40-, 128-, or 256-bit key lengths and permissions governing printing, extraction, accessibility extraction, form filling, modification, document assembly, and annotations. Review the installed command’s help for the exact required arguments and choose permissions to match the document’s intended use.

Be careful with output paths: if -o is omitted, the encrypt command can overwrite the original input. Preserve the source file and specify a separate output path when you need both versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Computer Programming For Teens
  • Used Book in Good Condition

Decrypt a PDF

PDFBox’s official command-line documentation states: “You must have the owner password to decrypt the document!” Certificate-encrypted PDFs may also require a keystore and alias. Use decrypt only with credentials you are authorized to use, and specify a separate output path: without one, decrypt can use the input path as its output.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Inspect, decompress, or print a PDF

Inspect internal structure

Run java -jar pdfbox-app-3.0.8.jar debug to open PDFDebugger and inspect a document’s internal PDF structure. The Apache command-line documentation identifies PDFDebugger as the replacement for PDFReader, which was removed in PDFBox 2.0.0.

The decode command decompresses PDF streams. This can make stream content easier to inspect with a text editor, but it does not turn every PDF into a readable text file: some data remains binary or uses PDF-specific structures.

Print a PDF

The print command sends a PDF to a printer. Its options cover printer selection, tray, media size, duplex, orientation, borders, DPI, and silent printing. The command depends on the machine’s printer configuration and requires appropriate printer permissions; check its help before scripting print jobs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Safer command-line workflow

  • Keep an unchanged copy of the input before encrypting, decrypting, importing data, or running any operation whose output may share the input path.
  • Specify output filenames explicitly when you need to preserve originals, and check whether the chosen output already exists before running a batch.
  • Try page ranges and output settings on a copy and a small sample before processing a large set.
  • Avoid placing passwords or certificate keystore paths directly in shell commands that may be saved in shell history. Use a safer credential-handling method appropriate to your operating system and environment.
  • Run -V and -h against the JAR you plan to use, then keep the version and options consistent across scripts.

License and download verification

PDFBox is open-source software distributed under the Apache License 2.0. The Apache download page provides the application JAR alongside signature and checksum files for download verification. Download from Apache and consult the license and verification information there if you need to confirm the terms or integrity of a copy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.