> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/security/security/redact.md).

# Applying redactions to PDFs

Apply redactions to PDFs easily using the WebViewer UI or programmatically. Learn how to set up fullAPI or webviewerServerURL for programmatically applying redactions. Use WebViewer Server for a promi

{% tabs %}
{% tab title="Standard API" %}
Redactions can be applied using the WebViewer UI or programmatically.

{% hint style="warning" %}
**Please Note!**

Even when programmatically applying redactions, `fullAPI` or `webviewerServerURL` must be set up. Furthermore when using WebViewer Server, `applyRedactions` will return a promise that resolves to a URL for the redacted document instead of updating the current document.
{% endhint %}

## Applying redactions with the WebViewer

A user can simply click on a redaction annotation and click on the apply button to apply a single redaction.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-8a769148b2a125d175bcccb3af01eb8fdb749706%2F21f841907524c7113abb805f7b3b0ec7b1a66a18-921x235.gif?alt=media)

There is also an 'Apply All' button that applies every redaction annotation in the document.

## Applying redactions programmatically

Redactions can be applied using the [applyRedactions function on AnnotationManager](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#applyRedactions__anchor). `applyRedactions` returns a promise and can be used to apply a single redaction, an array of redactions, or all redactions in a document. When using WebViewer Server, the returned promise will resolve to a response object with a URL to download the redacted document.

{% code lineNumbers="true" %}

```js
const redactionList = annotManager.getAnnotationsList().filter(annot => annot instanceof Annotations.RedactionAnnotation);

// apply a single redaction
annotManager.applyRedactions(redactionList[0])
  // When using WebViewer Server, 'results' will be a response object with a 'url' property for downloading the redacted document.
  .then(results => {
    return annotManager.applyRedactions(redactionList.filter(redaction => redaction.Author === 'User'));
    // When using WebViewer Server, the previous redaction will not appear in the results. It'll only redact the redactions provided to 'applyRedactions'.
    // However when using 'fullAPI', the document will have all previously applied redactions
  })
  .then(result => annotManager.applyRedactions());
```

{% endcode %}
{% endtab %}

{% tab title="Full API" %}
To redact content from a PDF document.

{% code lineNumbers="true" %}

```js
async function main() {
    const rarr = []; // we will contain a list of redaction objects in this array
    rarr.push(await PDFNet.Redactor.redactionCreate(1, (await PDFNet.Rect.init(100, 100, 550, 600)), false, 'Top Secret'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(30, 30, 450, 450)), true, 'Negative Redaction'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(0, 0, 100, 100)), false, 'Positive'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(100, 100, 200, 200)), false, 'Positive'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(300, 300, 400, 400)), false, ''));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(500, 500, 600, 600)), false, ''));
    rarr.push(await PDFNet.Redactor.redactionCreate(3, (await PDFNet.Rect.init(0, 0, 700, 20)), false, ''));

    const app = {};
    app.redaction_overlay = true;
    app.border = false;
    app.show_redacted_content_regions = true;

    const doc = await PDFNet.PDFDoc.createFromURL(filename);
    PDFNet.Redactor.redact(doc, rarr, app, false, false);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}

[PDF redaction](/web/get-started/samples.md#pdfredact) Full code sample which shows how to use `pdftron.PDF.Redactor` to remove potentially sensitive content within PDF documents.

## About redactor

Apryse Redactor makes sure that if a portion of an image, text, or vector graphics is contained in a redaction region, that portion of the image or path data is destroyed and is not hidden with clipping or image masks. Apryse SDK API can also be used to review and remove metadata and other content that can exist in a PDF document, including XML Forms Architecture (XFA) content and Extensible Metadata Platform (XMP) content.

The redaction process in Apryse SDK consists of two steps:

**1. Content identification** A user applies redact annotations that specify the pieces or regions of content that should be removed. The content for redaction can be identified either interactively (e.g. using ‘pdftron.PDF.PDFViewCtrl’ as shown in PDFView sample) or programmatically (e.g. using ‘pdftron.PDF.TextSearch’ or ‘pdftron.PDF.TextExtractor’). Up until the next step is performed, the user can see, move and redefine these annotations.

**2. Content removal** Using ‘pdftron.PDF.Redactor.Redact()’ the user instructs Apryse SDK to apply the redact regions, after which the content in the area specified by the redact annotations is removed. The redaction function includes number of options to control the style of the redaction overlay (including color, text, font, border, transparency, etc.).
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/security/security/redact.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
