---
title: "Adding redaction annotations to a PDF document | Nutrient Java SDK"
canonical_url: "https://www.nutrient.io/guides/java/editor/add-redaction-annotations-to-pdf/"
md_url: "https://www.nutrient.io/guides/java/editor/add-redaction-annotations-to-pdf.md"
last_updated: "2026-06-08T09:14:14.421Z"
description: "How to add redaction annotations to permanently remove sensitive content from PDFs using Nutrient Java SDK."
---

# Adding redaction annotations to a PDF document

Use redaction annotations to remove sensitive PDF content before distribution.

Common use cases include:

- Privacy and compliance workflows (for example GDPR and HIPAA)

- Legal and government document release

- Financial and HR document sanitization

- Internal review before external sharing

[Download sample](https://www.nutrient.io/downloads/samples/java/add-redaction-annotations-to-pdf.zip)

## Redaction annotation operations

Redaction involves the following steps:

- **Marking** — Define rectangular areas for removal.

- **Customization** — Configure redaction overlay appearance.

- **Execution** — Permanently delete underlying content.

- **Verification** — Confirm removed content isn’t recoverable.

Adding an annotation only marks content for removal. Sensitive content remains until redactions are applied.

## How Nutrient helps

Nutrient Java SDK handles redaction marking and content removal.

The SDK handles:

- PDF annotation structures and coordinate handling

- Redaction content removal behavior

- Overlay appearance and color configuration

- Save behavior for apply-now vs. review-first workflows

## Complete implementation

This example adds redaction annotations and configures save behavior.

### Packaging and imports

Specify the package name and import the required classes:

```java

package io.nutrient.Sample;

import io.nutrient.sdk.Document;
import io.nutrient.sdk.types.Color;
import io.nutrient.sdk.editors.PdfEditor;
import io.nutrient.sdk.editors.pdf.pages.PdfPageCollection;
import io.nutrient.sdk.editors.pdf.pages.PdfPage;
import io.nutrient.sdk.editors.pdf.annotations.PdfAnnotationCollection;
import io.nutrient.sdk.editors.pdf.annotations.PdfRedactAnnotation;
import io.nutrient.sdk.enums.PdfSavePreferences;
import io.nutrient.sdk.settings.PdfSettings;

public class RedactionAnnotations {

```

### Main entry point

Create the main method as the sample entry point:

```java

    public static void main(String[] args) {

```

### Initializing the editor and page

Open the document with try-with-resources, create an editor, and ensure a page exists:

```java

        try (Document document = Document.open("input.pdf")) {
            PdfEditor editor = PdfEditor.edit(document);
            PdfPageCollection pages = editor.getPageCollection();

            if (pages.getCount() == 0) {
                pages.add(612.0f, 792.0f);
            }

            PdfPage page = pages.getFirst();
            PdfAnnotationCollection annotations = page.getAnnotationCollection();

```

### Adding a redaction annotation

Mark a rectangular area for content removal.

The PDF coordinate system uses points (`1 inch = 72 points`), with the origin at the bottom-left corner:

```java

            PdfRedactAnnotation redaction = annotations.addRedact(
                72.0f, 684.0f, 504.0f, 72.0f  // x, y, width, height (1 inch from left, 9.5 inches from bottom, 7 inches wide, 1 inch tall)
            );

```

### Customizing the redaction appearance

Set the redaction fill color. This color appears after the redaction is applied:

```java

            redaction.setInteriorColor(Color.fromArgb(255, 0, 0, 0));

```

### Configuring save preferences

Control when redactions are applied during save.

Set `PdfSavePreferences.None` to preserve annotations for review before permanent removal:

```java

            document.getSettings().getPdfSettings().setSavePreferences(PdfSavePreferences.None);

```

### Saving the document

Save the output and close the editor:

```java

            editor.saveAs("output.pdf");
            editor.close();
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

```

## Conclusion

Use this workflow to add redaction annotations:

1. Open the document with try-with-resources.

2. Create a `PdfEditor` and access the target page.

3. Add redaction annotations with position and size in points.

4. Set redaction appearance with `setInteriorColor()`.

5. Configure save preferences for review-first or apply-now behavior.

6. Save the document and close the editor.

For related document workflows, refer to the [Java SDK guides](https://www.nutrient.io/guides/java.md).
---

## Related pages

- [Adding annotations to a PDF document](/guides/java/editor/add-annotations-to-pdf.md)
- [Adding a custom page to a PDF document](/guides/java/editor/add-custom-page-to-pdf.md)
- [Adding interactive form fields to a PDF document](/guides/java/editor/add-form-fields-to-pdf.md)
- [Adding free text annotations to a PDF document](/guides/java/editor/add-freetext-annotations-to-pdf.md)
- [Adding invisible digital signatures to a PDF document](/guides/java/editor/add-invisible-signature-to-pdf.md)
- [Adding link annotations to a PDF document](/guides/java/editor/add-link-annotations-to-pdf.md)
- [Adding stamp annotations to a PDF document](/guides/java/editor/add-stamp-annotations-to-pdf.md)
- [Adding sticky note annotations to a PDF document](/guides/java/editor/add-sticky-note-annotations-to-pdf.md)
- [Adding text markup annotations to a PDF document](/guides/java/editor/add-text-markup-annotations-to-pdf.md)
- [Advanced digital signature workflows](/guides/java/editor/advanced-digital-signatures.md)
- [Adding shape annotations to a PDF document](/guides/java/editor/add-shape-annotations-to-pdf.md)
- [Editing PDF metadata with Nutrient Java SDK](/guides/java/editor/editing-pdf-metadata.md)
- [Adding visible digital signatures to a PDF document](/guides/java/editor/add-visible-signature-to-pdf.md)
- [Editing PDF form fields](/guides/java/editor/editing-pdf-form-fields.md)
- [Detecting and adding form fields to a PDF document](/guides/java/editor/detect-and-add-form-fields.md)
- [Managing PDF page order](/guides/java/editor/manage-pdf-page-order.md)
- [Nutrient Java SDK editor guides](/guides/java/editor.md)
- [Filling PDF form fields](/guides/java/editor/fill-pdf-form.md)
- [Merging PDFs](/guides/java/editor/merge-pdf-into-other-pdf.md)

