Nutrient Java SDK
Need pricing or implementation help? Talk to Sales.
PDF REDACTION IN JAVA
import io.nutrient.sdk.Document;import io.nutrient.sdk.types.Color;import io.nutrient.sdk.editors.PdfEditor;import io.nutrient.sdk.editors.pdf.pages.PdfPage;import io.nutrient.sdk.editors.pdf.annotations.PdfAnnotationCollection;import io.nutrient.sdk.editors.pdf.annotations.PdfRedactAnnotation;
public class Redaction { public static void main(String[] args) { try (Document document = Document.open("input.pdf")) { PdfEditor editor = PdfEditor.edit(document); PdfPage page = editor.getPageCollection().getFirst(); PdfAnnotationCollection annotations = page.getAnnotationCollection();
// Mark a region for removal: x, y, width, height (points). PdfRedactAnnotation redaction = annotations.addRedact(72.0f, 684.0f, 504.0f, 72.0f); redaction.setInteriorColor(Color.fromArgb(255, 0, 0, 0));
// Saving applies the redaction and removes the content. editor.saveAs("output.pdf"); editor.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } }}import io.nutrient.sdk.Document;import io.nutrient.sdk.editors.PdfEditor;import io.nutrient.sdk.editors.pdf.pages.PdfPage;import io.nutrient.sdk.enums.PdfSavePreferences;
public class ReviewRedaction { public static void main(String[] args) { try (Document document = Document.open("input.pdf")) { PdfEditor editor = PdfEditor.edit(document); PdfPage page = editor.getPageCollection().getFirst();
// Mark a region, but don't remove the content yet. page.getAnnotationCollection() .addRedact(72.0f, 684.0f, 504.0f, 72.0f);
// Preserve marks for review instead of applying on save. document.getSettings().getPdfSettings() .setSavePreferences(PdfSavePreferences.None);
editor.saveAs("for-review.pdf"); editor.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } }}Define rectangular areas for removal by page coordinates, with full control over position, size, and overlay appearance.
Applying a redaction irreversibly deletes the underlying text and images from the file — the content can’t be recovered.
Run OCR to make scanned documents searchable. Then redact email addresses, phone numbers, and other sensitive text.
Sanitize documents for GDPR, HIPAA, and CCPA workflows before they’re shared, released, or archived.
Add redaction annotations to mark rectangular areas for removal by page coordinates.
Apply redactions to permanently delete the underlying content — it isn’t just hidden behind a box.
Control when redactions are applied with save preferences — review marks before committing, or remove on save.
Set the fill color shown in place of redacted content to match your output requirements.
Scanned documents have no searchable text. Run OCR first to expose the text, then redact it automatically.
Use redaction presets to find and remove common sensitive patterns without writing detection logic by hand.
Redaction is a two-step process — mark regions, then apply to remove them. Target text, images, and regions across privacy, legal, government, and HR workflows, all from a single Java API.
Text Images Regions Scanned pages Coordinates Preset patterns OCR text Overlay color GDPR HIPAA CCPA Secure removal HOW REDACTION WORKS
Redaction in the Java SDK is a two-step process: First, mark the regions you want to remove. Then, apply the redactions to permanently delete the underlying content. Separating the steps lets you review and adjust what will be removed before committing.
Add redaction annotations to mark regions first. Then apply to remove them. Adding a mark alone never deletes content.
Configure save preferences to preserve marks for a review pass, or apply redactions automatically when the document is saved.
Run OCR to make image-based pages searchable. Then use text or preset redaction to remove sensitive content from scans.
Position redaction regions precisely using the PDF point coordinate system, with the origin at the bottom-left of the page.
Redaction is a two-step process. First, add redaction annotations to mark the rectangular regions you want to remove, specifying their position and size in PDF points. Then, apply the redactions to permanently delete the underlying content. Until redactions are applied, marked content remains in the file. See the redaction annotations guide for more information.
Yes. Once redactions are applied, the underlying text and images are irreversibly deleted from the PDF — they aren’t hidden behind a black rectangle. The data is gone from the file, which is what regulations like GDPR and HIPAA require.
Yes. Adding a redaction annotation only marks content for removal — it doesn’t delete anything on its own. By configuring save preferences to preserve annotations, you can keep the marks for a review pass, inspect or adjust them, and apply the redactions permanently only when you’re ready.
Scanned documents are images and have no searchable text, so run OCR first to make the content recognizable. You can then redact the text using presets or pattern matching. Our OCR plus redaction tutorial walks through removing email addresses and phone numbers from a scanned letter end to end.
Yes. You define each redaction region by its position, width, and height using the PDF point coordinate system (1 inch = 72 points), with the origin at the bottom-left corner of the page. This is ideal when you know exactly where sensitive content sits — a header, stamp, or signature block, for example.
Yes. The redaction feature includes presets for common patterns such as email addresses and international phone numbers. You can add one or more presets and redact all matching occurrences in a single pass, without writing the detection logic yourself.
Nutrient Java SDK supports Java 8 and later, including Java 11, 17, and 21. You can deploy on any operating system that supports Java, including Windows Server, Linux servers, macOS, Docker containers, and cloud platforms like AWS, Azure, and Google Cloud. The same API works in both server-side and desktop applications.
The SDK uses a per-server licensing model based on the number of servers or containers running the SDK, not per document or per user. A single license allows unlimited document processing on that server, and it covers development, staging, and production environments. You can start with a free trial that includes full functionality to evaluate redaction in your environment.
Redaction across platforms
More Java SDK capabilities