Redaction is the process of removing content from a PDF page. This not only involves obscuring the content, but also removing the data in the document within the specified region.

Redaction is a two-step process.

  • First, redaction annotations have to be created in the areas that should be redacted. This step won’t remove any content from the document yet; it just marks regions for redaction.

  • Second, to actually remove the content, the redaction annotations need to be applied. In this step, the page content within the region of the redaction annotations is irreversibly removed.

For further in-depth information, check out the official Adobe document, PDF Redaction: Addendum for the PDF Reference.

PSPDFKit 5 for Android added a redaction feature with support for redacting text. However, it doesn’t yet support redacting any arbitrary regions or images in a document. Redaction support will be expanded upon in future versions. Using redaction requires the redaction component to be enabled in your license. Otherwise, all API calls related to redaction will fail, the UI will be hidden, and no RedactionAnnotations will be shown.

Creating Redactions


You can create redactions programmatically via RedactionAnnotation. Use the setRects() method to set the regions that should be covered by the redaction annotation.

You also have a few customization options for how a redaction should look, both while in its marked state, which is when the redaction has been created but not yet applied, and in its redacted state, which is when the redaction has been applied. It is not possible to change the appearance once a redaction has been applied, since the redaction annotation will be removed from the document in the process of applying the redactions. Here’s a list of available customization options for redactions:

  • setOverlayText() can be used to set the text that should be displayed at the specified region when a redaction has been applied.

  • setRepeatOverlayText() defines whether the overlay text should be drawn only once or repeated to fill the entire redaction area. This defaults to disabled, which means the overlay text is only drawn once. It has no effect if there is no overlay text specified.

  • setColor() can be used to change the color of the overlay text. It has no effect if there is no overlay text specified. This defaults to Color.RED.

  • setFillColor() specifies the background color of the redaction area after it has been applied. The color is drawn on all the specified rects. This defaults to Color.BLACK.

  • setOutlineColor() specifies the color used for the redaction’s border in its marked state. This defaults to Color.RED.

val text = "Guide"
val textPosition = document.getPageText(pageIndex).indexOf(text)
if (textPosition == 0) {
val textRects = document.getPageTextRects(pageIndex, textPosition, text.length, false)

val redaction = RedactionAnnotation(0, textRects)
redaction.color = Color.MAGENTA
redaction.fillColor = Color.BLACK
redaction.outlineColor = Color.YELLOW
redaction.overlayText = "REDACTED"

pdfFragment.addAnnotationToPage(redaction, false)
String text = "Guide";
final int textPosition = document.getPageText(pageIndex).indexOf(text);
if (textPosition == 0) {
final List<RectF> textRects = document.getPageTextRects(pageIndex, textPosition, text.length(), false);

RedactionAnnotation redaction = new RedactionAnnotation(0, textRects);

getPdfFragment().addAnnotationToPage(redaction, false);

The redaction annotation created with the above code snippet would look like what’s shown in the image below.

Marked State
Redacted State

User Interface

In addition to being able to create redactions programmatically, you can create and customize redactions via the UI PSPDFKit provides.

Adding a redaction to a document can be done by selecting the redaction tool on the annotation toolbar. This will enable the redaction mode and allow you to select text by dragging along. A redaction annotation will be created once you lift your finger.

Another way of creating a redaction is by first selecting text and then tapping the redaction item on the menu.

Once a redaction is added to the document, its properties and appearance can be customized via the annotation inspector.

Applying Redactions


There are two separate options for applying redactions programmatically.

  • Use PdfProcessorTask. This creates a new document and will leave the original document with the redaction annotations untouched:

val outputFile: File
val document: PdfDocument
val processorTask = PdfProcessorTask.fromDocument(document)

PdfProcessor.processDocument(processorTask, outputFile)
val redactedDocument = PdfDocumentLoader.openDocument(this, Uri.fromFile(outputFile))
File outputFile;
PdfDocument document;
PdfProcessorTask processorTask = PdfProcessorTask.fromDocument(document)

PdfProcessor.processDocument(processorTask, outputFile);
PdfDocument redactedDocument = PdfDocumentLoader.openDocument(this, Uri.fromFile(outputFile));
val documentSaveOptions = DocumentSaveOptions(null, null, true, null);
DocumentSaveOptions documentSaveOptions = new DocumentSaveOptions(null, null, false, null);

Both options will remove the redaction annotations in the process of redacting the content.

User Interface

Once there are redactions in the document, a floating redaction info button is shown in the user interface view. Tapping this button reveals a UI to apply redactions in the document. Tapping the Apply Redactions button will allow you to overwrite the current document or save the redacted version to a new location and remove the content in the area of the redaction annotations irreversibly. Tapping the Clear Redactions button will remove all redaction annotations. This can be undone using the regular undo button. In the process of redacting the content, all redaction annotations are removed from the document.

Note that when opening a document with existing redactions, there may be a delay before showing the button, since we need to check the document for redactions.

Previewing Redactions


To preview redactions and see how they would look when applied, without removing any document content, you can use the PdfFragment#setRedactionAnnotationPreviewEnabled() method:

pdfFragment.isRedactionAnnotationPreviewEnabled = true

User Interface

Redactions can be previewed by tapping on the floating redaction info button. When switching the preview mode on, all redaction annotations in a document will be rendered in their redacted state appearance (as opposed to the marked state that is otherwise always shown by default). This can be changed without having any content removed from the document. It is just for previewing purposes, and the actual removal of the document content will only happen when tapping the Apply Redactions button.

Custom Redaction UI

If you want to customize the UI to preview and apply redactions, you can disable the floating redaction info button in the user interface view via PdfActivityConfiguration.Builder#setRedactionUiEnabled(). Then you can roll your own UI to indicate uncommitted redactions and handle previewing and applying redactions in your own way instead.

Redacting Graphic Objects Shared across Pages

Graphic objects — including images and vector graphics — can be reused across pages in a PDF. If a graphic object is redacted and reused, all instances of that graphic object will also be redacted.

This means that, for example, when you redact part of an image, the same part of the same image on another page will also be redacted. This is compatible with how Adobe Acrobat does it. A common example of this is if you have to redact a logo that is shown on each page.

❗Important: Even if the images look exactly the same, they could be separate images and not be redacted the same. Always be careful and review the redacted document when you’re done.


Redaction is a feature that has to be licensed. If this feature is not licensed, some model-level APIs and the UI will change to not function the way they are described in this article. The following list describes the expected behavior if Redaction is not part of your license: