Some test text!


Document Redaction in Salesforce

Getting Started

We recommend familiarizing yourself with the Overview page to learn how to correctly use a config.js file. You should also learn about readerControl before getting started.

WebViewer configuration required for redaction

In your LWC where you initialize WebViewer (you can check out pdftronWvInstance.js in our sample repository). This shows you how to enable redaction:

//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
}, viewerElement);

Note: You need to use the 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 out this link to learn more.

Creating redactions manually using the UI

Review this section 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. You can review searching documents in Salesforce here .

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

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



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

Creating redactions programmatically

Review this section for creating redactions programmatically. In Salesforce, the equivalent of instance is readerControl .

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.

Live demo

Check out this live demo hosted outside of Salesforce.

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.