The Apryse Fall 2026 Release is Here: Explore What's New

Server-Side PDF Redaction in Java

To redact a PDF in Java with the Apryse Server SDK, initialize PDFNet, identify the content to remove by creating redact annotations through text search or text extraction, then call the apply step to destroy the text, image and vector content inside those regions. The marking step is reversible; applying the redaction is not.

How Redaction Works in the Apryse Server SDK

Redaction in Java with the Apryse Server SDK takes two steps. Redact annotations mark the content to remove, and you can still see, move, and redefine them until you apply them. The apply step then destroys the text, image, and vector content inside each marked region, so nothing hides behind a clipping path or an image mask.

Your Java service decides which documents to process and what to mark. Apryse supplies the PDF redaction library that performs the removal, and financial services, healthcare, government, and legal teams run it before a document leaves their systems. For the cross-language view, read the PDF redaction SDK developer guide. The same two steps apply to server-side redaction in C# and to teams that redact PDFs in Python.

Setting Up: Initialization and Licensing

Copied to clipboard

This page covers the Apryse Server SDK as a Java PDF redaction SDK on Windows, Linux, and macOS. Follow the Java get-started guide to install it, then call PDFNet.initialize() with your license key once at service startup, before any other SDK method, and PDFNet.terminate() at shutdown. Start the JVM with the PDFNet native library on the Java library path, or the first call fails with an UnsatisfiedLinkError.

Redaction ships in the base binary and needs the Redaction add-on license on your production key. Get your free trial key at dev.apryse.com before running the code, or from the Server SDK trial key guide, and inject it through APRYSE_LICENSE_KEY rather than committing it to source control. Because the SDK processes documents locally, you can run redaction on your own infrastructure and no document data leaves it.

Identifying Content to Redact

Copied to clipboard

Identification produces the redact annotations, and you can create them interactively or programmatically. This page covers the programmatic path, because a JVM service has no reviewer at the keyboard. Your code locates the content through text search or text extraction, both base Server SDK capabilities, then marks the regions that hold it.

Pattern Matching for PII

Copied to clipboard

Pattern matching finds sensitive values without a fixed string, using ambient string matching, wildcards, or regular expressions. SSNs, credit card numbers, and other PII are the documented pattern examples. A financial services team can match card numbers across statements, and a records office can match SSNs before a public release. Your code decides whether each match is sensitive enough to mark.

Applying the Redaction

Copied to clipboard

The apply step is where redaction becomes permanent. The SDK destroys the text, image, and vector content inside every marked region instead of hiding it. You configure the overlay that replaces the content: color, text, font, border, and transparency. The operation cannot be undone, so keep the original and write the output as a new file.

This feature is included in the base Server SDK binary but requires a separate Redaction add-on license. See the capabilities page for licensing.

The example below applies one marked region to a statement and saves the result as a new file. Replace the hardcoded region with the regions your identification step produces.

The try-with-resources block closes the PDFDoc even when redaction throws, and the finally block terminates PDFNet once the work is done. Each Redaction carries a page number, a rectangle, a negative-mode flag, and the overlay text.

Verifying the Content Was Removed

Copied to clipboard

Verify the output before release. Run text search or text extraction on the redacted file for every value you targeted. A match means the content survived. A clean result is your evidence that it was destroyed.

Read the guide on true redaction versus visual masking for the failure this check catches: a black box drawn over text that stays extractable underneath. Run the check as an automated gate, so a file that still matches never leaves your service.

Resource Handling and Explicit Disposal

Copied to clipboard

Resource handling is where a Java service that redacts documents in a loop goes wrong first. Close each PDFDoc when you finish with it, and call PDFNet.terminate() once at shutdown. The example above and the Apryse Java sample both open the document in a try-with-resources block, which closes it even when redaction throws an exception. Follow that pattern instead of relying on garbage collection.

On worker threads, give each thread its own PDFDoc, because sharing one document across threads without locking produces undefined behavior, including crashes. The original walkthrough shows how to redact PDFs in Java step by step.

What the Server SDK Does and Does Not Do

Copied to clipboard

Redaction ends at the PDF the SDK writes. Your service owns storage, review, and release. Redaction removes visible content. Sanitization, a separate base-package capability, removes hidden data such as metadata, embedded scripts, form data, and hidden layers. Read redaction versus sanitization for the boundary and PDF sanitization for the hidden-data side.

The Server SDK provides no work queue, job scheduler, or batch orchestration. Your code owns the loop, the parallelism, and the retries. See redacting documents in bulk for the pattern.

Support and Licensing Matrix

Copied to clipboard
Capability
Server SDK (Java)
True content removal
Yes. Text, image, and vector content inside marked regions is destroyed, not hidden with clipping paths or image masks.
Search and redact
Yes. Text search or text extraction identifies the content to mark.
Pattern matching
Ambient string, wildcards, and regular expressions. SSNs, credit card numbers, and other PII are the documented examples.
Overlay configuration
Color, text, font, border, and transparency.
Headless operation
Yes. Runs as a library inside your own service with no viewer UI. Documents are processed locally.
License requirement
Redaction add-on license. Ships in the base binary with no separate download. The Redaction Package must be on the production license key. Trial keys include all packages.
Sanitization of hidden data
Not part of Redaction. Sanitization is a separate capability in the base Server SDK package.

Get-Started Guides by Language

Sanity Image
Sanity Image
Sanity Image
Sanity Image

Frequently Asked Questions

Initialize PDFNet, create redact annotations to mark the regions or text to remove, then call the apply step. The apply step destroys the text, image, and vector content inside the marked regions rather than hiding it. The operation is irreversible.

Yes. Your code can identify content through text search or text extraction, and pattern matching supports ambient string, wildcards, and regular expressions. SSNs, credit card numbers, and other PII are the documented pattern examples.

No. Redaction removes visible page content inside the marked regions. Metadata, embedded scripts, form data, and hidden layers are removed by Sanitization, a separate Server SDK capability included in the base package.

Redaction follows the base Server SDK runtime requirements, and the Java get-started guide lists JDK 25 (LTS). Java 17 does not appear in that requirement, so confirm your JDK version against the guide before you plan a deployment.

Yes. Close each PDFDoc after you process it, and call PDFNet.terminate() at application shutdown. The Java sample opens the document in a try-with-resources block so it closes even when redaction throws. Follow that pattern rather than relying on garbage collection, particularly in a long-running service that processes documents in a loop.

A Redaction add-on license. The Redaction Package must be on your production license key. Redaction ships in the base Server SDK binary, so there is no separate module to download, and trial keys include all packages.

Loop over the documents and apply the same detection and apply steps to each. The Server SDK provides no work queue, job scheduler, or batch orchestration, so your code owns the loop, the parallelism, and the retry behavior.

Start Redacting PDFs in Java

Install the Server SDK, request a trial key, and run the redaction sample against your own documents. Trial keys include every add-on package.