How to Create a Script for Automatically Removing Information from a Document

You can use scripts to redact information from recognized text:

1. Hide this information in detected blocks.
To do so, call the RedactRegion method for the selected block in the indexing script.
Note. This method is not suitable for barcode blocks.
To edit all detected text blocks in a document, add the following sample code to your script:

 //JScript
 for( var p = 0, pc = this.Pages.Count; p < pc; p++){
   var page = this.Pages.Item(p);
   for(var tb = 0, tbc = page.TextBlocks.Count; tb < tbc; tb++){
       var textBlock = page.TextBlocks.Item(tb);
       page.RedactRegion(textBlock.Region);
   }
 }
 this.SkipManualIndexing = true;

2. Edit index fields.
To do so, call the RedactRegion method for the selected index field in the IndexingFinished script.
To edit all index fields for the selected document type, add the following sample code to your script:

 //JScript
 var pagesCount = this.DocumentPages.Count;
 for( var a = 0, ac = this.Attributes.Count; a < ac; a++) {
    var attribute = this.Attributes.Item(a);
    var pageIndex = attribute.PageIndex;
    if( pageIndex >= 0 && pageIndex < pagesCount ){
        this.DocumentPages.Item(pageIndex).RedactAttribute(attribute);
    }
 }

20.09.2022 9:27:51

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.