How to redact sensitive text in FlexiCapture with script?

Question

Can I replace sensitive information in output file with custom image ?

Answer

If it is required to redact text of specific field, check the common options of fields redaction in FlexiCapture (), or dedicated Help Center article for scripting options (How to redact a field in FlexiCapture with script?)

If the text is not in the field, or if you need to redact only part of the field text, you shall refer to the text coordinates to set the regions for redaction. 

Use the page scripting object IPage properties "FullText" and "FullTextCharRects" to find the text you would like to redact and get its coordinates.

Note. If you want to redact part of the field text you may get field characters regions from IField "Symbols" property (ICharactersParams scripting object).

Example 

//C# script sample for document processing script stage
//Find the characters positions of text "Invoice No" we want to redact at the first document page image
string s = Document.Pages[0].FullText;
string ss = s.Substring(0,s.LastIndexOf("Invoice No")+10); //10 is "Invoice No" text length
int sl = ss.Length;

// Find the characters coordinates of starting "I" and ending "o" in "Invoice No"
IRect rectI = Document.Pages[0].FullTextCharRects[sl-10];
IRect recto = Document.Pages[0].FullTextCharRects[sl-1];

//Create the coordinates of the region covering "Invoice No" text from starting and ending letters coordinates
string redact = string.Format("[{0},{1},{2},{3}]",rectI.Left.ToString(),rectI.Top.ToString(),recto.Right.ToString(), recto.Bottom.ToString());

//Replace the page image with image where "Invoice No" text is redacted
IEditablePictureObject eidtablePictureObject = Document.Pages[0].Picture.CreateEditableCopy();
eidtablePictureObject.Erase(redact);
Document.Pages[0].ReplaceImage(eidtablePictureObject);

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed