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:

C#
DocumentRedactionOptions redactionOptions = 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:

C#
DocumentRedactionOptions redactionOptions = new 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 (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 when it is using the default values:

C#
.ConvertOptions.Mode = AnnotationsRedactionMode.None; 
.ViewOptions.Mode = 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:

C#
// First, determine if this document has redaction options. If not, create a default one. 
if (leadDocument.Annotations.RedactionOptions != null) 
   leadDocument.Annotations.RedactionOptions = new DocumentRedactionOptions(); 
// Now, set the options to apply the redactions on view and convert 
leadDocument.Annotations.RedactionMode.ViewOptions.Mode = AnnotationsRedactionOptions.Apply; 
leadDocument.Annotations.RedactionMode.ConvertOptions.Mode = 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 action 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

Loading Using LEADTOOLS Document Library

Creating Documents with LEADTOOLS Document Library

Document Toolkit and Caching

Document Library Coordinate System

Uploading Using the Document Library

Loading Encrypted Files Using the Document Library

Parsing Text with the Document Library

Barcode processing with the Document Library

Document Toolkit History Tracking

Document Page Transformation

Using LEADTOOLS Document Viewer

Using LEADTOOLS Document Converters

Related Topics

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

LEADTOOLS Imaging, Medical, and Document