←Select platform

ActionElement Class

Summary

Defines an action to be run after the document analyzer has finished inspecting the document.

Syntax
C#
VB
C++
public abstract class ActionElement 
Public MustInherit Class ActionElement 
public: 
   ref class ActionElement abstract 
Remarks

To implement a custom action, derive from this class and implement the Run() function.

Any number of public properties for the custom type can be implemented.

This action receives the document and the analysis results and can perform tasks to edit the document accordingly.

ActionElement also can be saved and restored from DocumentAnalyzerRepository.

Example

This example shows how to define a custom action.

C#
using Leadtools; 
using Leadtools.Document.Analytics; 
using Leadtools.Document; 
using Leadtools.Document.Unstructured; 
 
 
public class RedactAction : ActionElement 
{ 
   public RedactAction() 
   { 
      Id = "REDACT_DOCUMENT"; 
   } 
 
   public override void Run(LEADDocument document, IList<ElementSetResult> results) 
   { 
      //process(document, results.Items); 
      //save(document); 
   }          
} 
 
public void Sample() 
{ 
   var leadDoc = DocumentFactory.LoadFromFile(@"c:\test.docx", new LoadDocumentOptions()); 
   var analyzer = new DocumentAnalyzer(); 
   var elem = new UnstructuredElementSet() { Name = "Test", Element = CreateElement() }; 
   var actions = new ActionElementSet(); 
   actions.ActionElements.Add(new RedactAction()); 
 
   var runOptions = new DocumentAnalyzerRunOptions() 
   { 
      ElementSet = new List<IElementSet>() { elem } 
      Actions = actions 
   }; 
 
   analyzer.Run(leadDoc, runOptions); 
} 
 
private static GroupElement CreateElement() 
{ 
   GroupElement mainGroup = new GroupElement(); 
   mainGroup.Id = "ALL"; 
   mainGroup.Settings.SetValue(SettingsManager.Name, "all"); 
   mainGroup.Settings.SetValue(SettingsManager.ReportInElementResult, "true"); 
   mainGroup.Settings.SetValue(SettingsManager.Description, "Rules"); 
   mainGroup.Settings.SetValue(SettingsManager.Languages, "en"); 
                   
   return mainGroup; 
} 
Requirements

Target Platforms

Help Version 22.0.2021.9.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Analytics Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.