Question / Problem:
How Do I Create Dynamic Masking Areas in KTM Validation?
Answer / Solution:
Documents processed in KTM may obtain sensitive information that should not be seen by Validation Operations. A good example is the Social Security Number (SSN) in the USA. This number is required to open a bank account, buy a car, and much more. To prevent criminal activity, it is mandatory to mask the SSN number during data entry on Documents where other personal information is also printed.
A solution for this is to create masking areas on the document in KTM Validation. This can be done manually on fixed areas, but also dynamically with scripting. Coming back to the use case mentioned above, it is possible to have a Format Locator which finds all SSN numbers on a document and KTM script in the event ValidationForm_DocumentLoaded to create Masking Zones based on the coordinates of the Format Locator alternatives.
Attached is a project solution for the problem scenario presented along with sample images:
Private Sub ValidationForm_DocumentLoaded(ByVal pXDoc As CASCADELib.CscXDocument) ' check in which Validation step the batch is loaded in. ' MaskingAreas are only added in Validation step 1 If Project.ScriptExecutionInstance = 1 Then Dim oMaskingZone As CscScriptMaskedArea Dim iNumberOfMaskingZones As Integer Dim i As Integer ' delete all MaskingAreas which have been created before ' (all manual created zones and all zones created when the batch has been loaded in ' Validation step 1 before) For iNumberOfMaskingZones = ValidationForm.MaskedAreas.Count - 1 To 0 Step -1 ValidationForm.MaskedAreas.Remove(iNumberOfMaskingZones) Next iNumberOfMaskingZones ' loop through all alternatives of the Format Locator "SSL" For i = 0 To pXDoc.Locators.ItemByName("SSL").Alternatives.Count - 1 ' create MaskingAreas only for alternatives with a confidence of 90 If pXDoc.Locators.ItemByName("SSL").Alternatives(i).Confidence = 0.9 Then Set oMaskingZone = ValidationForm.MaskedAreas.Create() ' set the MaskingAreas dynamically for the best alternative of ' the FormatLocator "SSL" If pXDoc.Locators.ItemByName("SSL").Alternatives.Count > 0 Then oMaskingZone.Left = pXDoc.Locators.ItemByName("SSL").Alternatives(i).Left - 10 oMaskingZone.Top = pXDoc.Locators.ItemByName("SSL").Alternatives(i).Top - 10 oMaskingZone.Height = pXDoc.Locators.ItemByName("SSL").Alternatives(i).Height + 20 oMaskingZone.Width = pXDoc.Locators.ItemByName("SSL").Alternatives(i).Width + 20 oMaskingZone.PageIndex = pXDoc.Locators.ItemByName("SSL").Alternatives(i).PageIndex End If End If Next i End If End Sub