Some test text!
Salesforce / Guides / Redaction
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.
We recommend familiarizing yourself with the Overview 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
before getting started.
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
// l: 'YOUR_LICENSE_KEY_HERE',
}, viewerElement);
Note: You need to use the pdf_full.zip
file in your /staticresources/
folder to access full API, which is required for redaction.
To perform redaction on a document, open it in WebViewer. Check opening documents guide to learn more.
Review creating redaction guide for creating redactions with the WebViewer UI.
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 .
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 = 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);
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);
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.
Review the guide for creating redaction for more on creating redactions programmatically.
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.
Check out this live redaction demo (hosted outside of Salesforce).
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales