Link
Skip to main content

Sanitize PDF files

v2025.09

JPedal provides a PdfManipulator class which includes several document sanitization features.

To get started, use the following code snippet:

final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));

// Now choose one or more of the below options to insert here
        
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
pdf.closeDocument();
pdf.reset();

Remove JavaScript

The PDF Manipulator provides the following methods for detecting and removing the presence of JavaScript in PDF files.

boolean containsJS = pdf.containsJavaScript();
pdf.removeJavaScript();

You do not need to call containsJavaScript() in order to call removeJavaScript()

Remove Metadata

The PDF Manipulator provides the following method for removing metadata from PDF files.

pdf.removeMetadata();

Remove Embedded Files

The PDF Manipulator provides the following method for removing embedded/attached files from PDF files.

pdf.removeEmbeddedFiles();

Learn more about the PdfManipulator.


Why JPedal?

  • Actively developed commercial library with full support and no third party dependencies.
  • Process PDF files up to 3x faster than alternative Java PDF libraries.
  • Simple licensing options and source code access for OEM users.

Learn more about JPedal

Start Your Free Trial


Customer Downloads

Select Download