> 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/redaction/redact.md).

# Redacting PDFs in UI or Programmatically using JavaScript

Redact PDFs effortlessly using JavaScript, either through the WebViewer UI or programmatically. Learn how to apply redactions seamlessly  for secure document editing. The Apryse Web SDK streamlines se

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#Redaction" class="button primary">Package: Redaction</a><a href="https://showcase.apryse.com/redaction" class="button primary">Live demo</a>
{% endhint %}

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 WebViewer

A user can simply click on a redaction annotation and click on the apply button to apply a single redaction. Try this out now with our [redaction demo](https://showcase.apryse.com/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.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
// Get the list of redactions
const redactionList = annotationManager.getAnnotationsList().filter(annot => annot instanceof Annotations.RedactionAnnotation);

// apply a single redaction
annotationManager.applyRedactions(redactionList[0])

// apply annotations created by a specific User
annotationManager.applyRedactions(redactionList.filter(redaction => redaction.Author === 'User'));

// Apply all redactions
annotationManager.applyRedactions(redactionList)
 
```

{% endcode %}
{% 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
