Document View and Convert Redaction

The LEADTOOLS Document Library supports redacting sensitive information on documents with view and convert options.

Access these options through the DocumentAnnotations.RedactionOptions property of a LEADDocument object, as follows:

var redactionOptions /*:lt.Document.DocumentRedactionOptions*/ = leadDocument.annotations.redactionOptions; 
By default, the value is null. Therefore, when loading from a URI or creating new documents the application creates a new instance of DocumentRedactionOptions and sets it first, as follows:
var redactionOptions = new lt.Document.DocumentRedactionOptions(); 
// Modify redactionOptions as needed, then set it: 
leadDocument.annotations.redactionOptions = redactionOptions; 

DocumentRedactionOptions contains the following properties:

Currently, both ViewRedactionOptions and ConvertOptions derive from AnnotationsRedactionOptions, and contain the following properties:

Example

This example shows how to redact a document for viewing and redaction using the LEADTOOLS Document Viewer Demo. Each step is explained with code snippets showing how to set the options to perform the actions.

Step 1

Start with the document viewer demo (JavaScript or Desktop) and load the source document containing the text to be redacted.

This screenshot shows a loaded account balance PDF file:

document-redact1.png

This document contains sensitive information that needs to be redacted. The information is the Account Number, with a value of 12345678-123, shown highlighted below:

document-redact2.png

Use the Annotation Redaction object (AnnRedactionObject) from the annotation menu to draw a redaction around the account number:

document-redact3.png

It is also possible to use the text redaction object (AnnTextRedactionObject) to perform the same action.

Step 2

Save the document using File/Save to cache, and then re-open it with the same document ID. Notice that the redaction object is visible and covers the account number value. However, the redaction can still be selected, or moved or deleted to uncover the sensitive information:

document-redact4.png

This is because the redaction object is a live object and is only rendered on top of the document. The object is also included in the Annotations Objects list and can be interacted with just like any normal annotation object.

Step 3

Perform a select text operation on the text and notice that the sensitive information can be selected and copied to the clipboard as well:

document-redact5.png

When exporting this document to an external PDF or DOCX, the information will be visible as well.

This behavior occurs when the value of LEADDocument.annotations.redactionOptions is null or is using the default values of:

.convertOptions.mode = lt.Document.AnnotationsRedactionMode.none; 
.viewOptions.mode = lt.Document.AnnotationsRedactionMode.none; 

In this mode, no special processing is performed on the document while it is being viewed. To perform true redaction, select Annotations/Redaction Options from the menu and change the Redaction Mode for View and Convert as follows, and click OK:

document-redact6.png

Setting these options calls the following:

// First, determine if this document has redaction options. If not, create a default one. 
if (!leadDocument.annotations.redactionOptions) 
   leadDocument.annotations.redactionOptions = new lt.Document.DocumentRedactionOptions(); 
// Now, set the options to apply the redactions on view and convert 
leadDocument.annotations.redactionMode.viewOptions.mode = lt.Document.AnnotationsRedactionOptions.apply; 
leadDocument.annotations.redactionMode.convertOptions.mode = lt.Document.AnnotationsRedactionOptions.apply; 

Step 4

After clicking OK, note that the document is re-loaded from the cache and now looks as follows:

document-redact7.png

The first thing to notice is the redaction object has been removed from the list of Objects, although it is still visible on the document and the thumbnail. Trying to interact with the object yields no actions (it is a physical part of the page now and cannot be moved or deleted).

Step 5

Perform a select text operation on the text and notice that the sensitive information is redacted with the selected character (the default of *):

document-redact8.png

Redaction is performed because the value of leadDocument.annotations.redactionMode.viewOptions.mode is set to AnnotationsRedactionOptions.apply. This instructs the library to apply the redaction objects on each page inside the document itself (or on the server) before passing it to the viewer. DocumentPage.getImage, DocumentPage.getSvg and DocumentPage.getThumbnailImage all perform the redaction and return a redacted image that does not contain any sensitive information. For a raster image, the redaction is rendered on the pixels' data. For SVG, the redaction is performed by removing the characters from the text elements and replacing them with the redaction character.

Step 6

Select File/Export to save this document to an external PDF or DOCX file. Notice that the resulting document is redacted as well and does not contain any sensitive information. The following screenshot shows the output document displayed in a Chrome browser with the account number selected:

document-redact9.png

Notice that the document stays "text" and only the redacted area is modified. This behavior is performed because the value of leadDocument.annotations.redactionMode.convertOptions.mode is set to AnnotationsRedactionOptions.apply. This instructs the library to apply the redaction objects on each page inside the document itself (or on the server) before passing it to the document converter. DocumentPage.getImage, DocumentPage.getSvg, DocumentPage.getThumbnailImage, and DocumentPage.getText all perform the action and return a redacted image that does not contain any sensitive information, similar to the view options described above.

The annotations redaction object still lives inside the document. With these options set, it is applied on demand and removed from the annotations list of the document when viewed or converted. Go back into the document viewer and select Annotations/Redaction Options again and set the values of View/Redaction Mode and Convert/Redaction Mode back to the default value of None. After clicking OK, notice that the viewer reloads the document and now the redaction annotation object is live again and can be interacted with. Selecting the text of the account number shows that the original un-redacted value has been restored:

document-redact10.png

Notes

See Also

Document Library Features

Document Viewer Application

Loading Documents Using the LEADTOOLS Document Library

Creating Documents with LEADTOOLS Document Library

Document Toolkit and Caching

Uploading Using the Document Library

Document Library Coordinate System

Loading Encrypted Files Using the Document Library

Parsing Text with the Document Library

Barcode processing with the Document Library

Using jQuery Promises in the Document Library

Loading Images in the Document Library

Document Page Transformation

Using LEADTOOLS Document Viewer
Status Document Job Converter

Related Topics

Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Help Version 23.0.2024.5.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS HTML5 JavaScript
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.