Process and Manipulate PDF Files in Java
JPedal is a pure Java PDF library for processing and manipulating PDF files programmatically, including merging, splitting, redacting, digitally signing, sanitizing and optimizing PDF documents.
Requirements
| Requirement | Value |
|---|---|
| Minimum Java version | Java 17 |
| Third-party dependencies | None |
Merge PDF Files
JPedal can combine multiple PDF files into a single document programmatically in Java. The merged output preserves fonts, images and page structure from each input file.
Split PDF Files
JPedal can split a PDF into individual pages, or into smaller documents covering user-defined page ranges. For example, a 100-page document can be split into ten 10-page documents.
Delete PDF Pages
JPedal can delete pages from a PDF file, removing all the associated page content and any references to it.
Delete pages from a PDF in Java
Digitally Sign PDF Files
JPedal supports adding digital signatures to PDF files, enabling document authentication and integrity verification workflows. Other software can then validate signed files to detect any subsequent modifications.
Sanitize PDF Files
JPedal can sanitize PDF files by removing potentially harmful content, including JavaScript, embedded files and launch actions, making it suitable for ingestion pipelines handling PDFs from untrusted sources.
Optimize PDF Files
JPedal can reduce PDF file size by removing unused objects, flattening layers and rewriting the internal structure, reducing storage costs and improving load times.
Redact PDF Files
JPedal can permanently remove sensitive text from PDF files. Redacted content is removed from the PDF structure and cannot be recovered. To remove metadata, use the sanitize function.
Manipulate PDF Pages
JPedal supports page-level manipulation including adding, copying, deleting, rotating, redacting, resizing, and n-up imposition (combining multiple pages onto a single output page).
Process a PDF from the command line or another language
# Merge two PDF files
java -cp jpedal.jar org.jpedal.tools.PdfMerge inputFile1.pdf inputFile2.pdf outputFile.pdf
The command line interface can be invoked from any language that supports child processes, including Python, Node.js, C#, and shell scripts. See the individual tutorial pages for operation-specific CLI flags.
Frequently Asked Questions
Can JPedal merge PDF files in Java?
Yes. JPedal can combine multiple PDF files into a single document. The merged output preserves the content of all input files, including fonts, images, and page structure.
Can JPedal split a PDF into individual pages?
Yes. JPedal can split a PDF into single pages or into documents covering a user-defined page range. For example, a 100-page document can be split into ten equal documents.
What does PDF redaction do and is it permanent?
Redaction permanently removes text from the PDF structure so it cannot be recovered. Metadata can be removed using the sanitize function.
Can JPedal redact text matched by a search?
Yes. JPedal’s text search returns page coordinates that can be passed directly to the redaction API, enabling pattern-based redaction across a document or batch.
Does JPedal support digital signatures?
Yes. JPedal supports adding PAdES Baseline Level B digital signatures to PDF files.
Can JPedal remove JavaScript and active content from a PDF?
Yes. The sanitize function removes JavaScript, embedded files, launch actions and other active content that could pose a security risk.
Can JPedal add, delete or reorder pages?
Yes. JPedal supports adding, copying, deleting, rotating and resizing pages, as well as n-up imposition.
How does JPedal reduce PDF file size?
JPedal’s optimize function removes unused objects, flattens layers and rewrites the PDF structure to be more compact.
Can I process PDF files without writing Java code?
Yes. JPedal includes a command-line interface that can be invoked from any language that supports child processes, including Python, Node.js, C# and shell scripts.
Can JPedal process password-protected PDF files?
Yes. Pass the password as a byte array when you load the file: pdfManipulator.loadDocument(new File("input.pdf"), "password".getBytes()). Both user and owner passwords are supported.
Does JPedal require any third-party libraries for PDF processing?
No. 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?