> 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/salesforce/redaction/redacting-documents-salesforce.md).

# Document Redaction in Salesforce

Learn how to utilize Apryse's PDF Redaction capabilities in Webviewer with Salesforce Lightning Components. Get started with redacting documents securely and efficiently. Salesforce WebViewer adds acc

Apryse offers PDF Redaction, a safe and secure removal of content on document formats such as PDF. This guide will help you utilize all of Apryse's Redaction capabilities in Webviewer alongside Salesforce Lightning Components.

{% embed url="<https://www.youtube.com/embed/ws1UUjMHK1g>" %}

## Getting Started

We recommend familiarizing yourself with the [Overview](/salesforce/get-started/readme.md) page to learn how to correctly use a `config.js` file. If you are using a version of WebViewer older than `8.0+`, you should also learn about [`readerControl`](/salesforce/get-started/readme.md) before getting started.

## WebViewer configuration required for redaction

In your LWC where you initialize WebViewer (you can check out [`pdftronWvInstance.js`](https://github.com/ApryseSDK/salesforce-pdf-app/blob/main/force-app/main/default/lwc/pdftronWvInstance/pdftronWvInstance.js) in our sample repository). This shows you how to enable redaction:

<pre class="language-js" data-line-numbers><code class="lang-js">//snipped for brevity
const viewerElement = this.template.querySelector('div');

const viewer = new PDFTron.WebViewer({
    path: libUrl,
    custom: JSON.stringify(myObj),
    config: myfilesUrl + '/config_apex.js',
    fullAPI: true // this must be set to true
    enableRedaction: true, // this must be set to true
    // l: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>_HERE',
}, viewerElement);
</code></pre>

Note: You need to use the `pdf_full.zip` file in your `/staticresources/` folder to access full API, which is required for redaction.

## Open a document

To perform redaction on a document, open it in WebViewer. Check [opening documents guide](/salesforce/open-save/opening-documents-salesforce.md) to learn more.

## Creating redactions manually using the UI

Review [creating redaction guide](/web/redaction/creating-redaction.md#creating-redactions-with-the-ui) for creating redactions with the WebViewer UI.

## Search and redact

You can use search to highlight single or all occurences of a search term. You may also use regular expressions, which allows to target e-mail addresses, phone numbers, credit card numbers, etc. See more in our [searching documents guide](/salesforce/search/searching-documents-salesforce.md).

When performing your search, add a `searchListener` that marks your search results for redaction like so:

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

```js
const searchListener = (searchTerm, options, results) => {
    // add redaction annotation for each search result
    const newAnnotations = results.map(result => {
        const annotation = new Annotations.RedactionAnnotation();
        annotation.PageNumber = result.pageNum;
        annotation.Quads = result.quads.map(quad => quad.getPoints());
        annotation.StrokeColor = new Annotations.Color(136, 39, 31);
        return annotation;
    });

    annotManager.addAnnotations(newAnnotations);
    annotManager.drawAnnotationsFromList(newAnnotations);
};

instance.addSearchListener(searchListener);
```

{% endcode %}
{% endtab %}
{% endtabs %}

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

```js
const searchListener = (searchTerm, options, results) => {
    // add redaction annotation for each search result
    const newAnnotations = results.map(result => {
        const annotation = new Annotations.RedactionAnnotation();
        annotation.PageNumber = result.pageNum;
        annotation.Quads = result.quads.map(quad => quad.getPoints());
        annotation.StrokeColor = new Annotations.Color(136, 39, 31);
        return annotation;
    });

    annotManager.addAnnotations(newAnnotations);
    annotManager.drawAnnotationsFromList(newAnnotations);
};

readerControl.addSearchListener(searchListener);
```

{% endcode %}
{% endtab %}
{% endtabs %}

Then run your search using either `instance.searchText(searchTerms, searchOptions)` or `instance.searchTextFull(searchTerms, searchOptions)`. Once you have the desired search term(s) highlighted, you can call `instance.Core.documentViewer.getAnnotationManager().applyRedactions();` to redact these items.

## Creating redactions programmatically

Review the [guide for creating redaction](/web/redaction/creating-redaction.md#creating-redactions-programmatically) for more on creating redactions programmatically.

## Sample project

You can review the Salesforce PDF App to showcase an end-to-end example of search, and how you can leverage it for redaction and content replacing on our [Github repository](https://github.com/ApryseSDK/salesforce-pdf-app/).

## Live demo

Check out this live [redaction demo](https://showcase.apryse.com/redaction) (hosted outside of Salesforce).


---

# 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/salesforce/redaction/redacting-documents-salesforce.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.
