activities
latest
false
- Overview
- Document Processing Contracts
- Release notes
- About the Document Processing Contracts
- Box Class
- IPersistedActivity interface
- PrettyBoxConverter Class
- IClassifierActivity Interface
- IClassifierCapabilitiesProvider Interface
- ClassifierDocumentType Class
- ClassifierResult Class
- ClassifierCodeActivity Class
- ClassifierNativeActivity Class
- ClassifierAsyncCodeActivity Class
- ClassifierDocumentTypeCapability Class
- ExtractorAsyncCodeActivity Class
- ExtractorCodeActivity Class
- ExtractorDocumentType Class
- ExtractorDocumentTypeCapabilities Class
- ExtractorFieldCapability Class
- ExtractorNativeActivity Class
- ExtractorResult Class
- ICapabilitiesProvider Interface
- IExtractorActivity Interface
- ExtractorPayload Class
- DocumentActionPriority Enum
- DocumentActionData Class
- DocumentActionStatus Enum
- DocumentActionType Enum
- DocumentClassificationActionData Class
- DocumentValidationActionData Class
- UserData Class
- Document Class
- DocumentSplittingResult Class
- DomExtensions Class
- Page Class
- PageSection Class
- Polygon Class
- PolygonConverter Class
- Metadata Class
- WordGroup Class
- Word Class
- ProcessingSource Enum
- ResultsTableCell Class
- ResultsTableValue Class
- ResultsTableColumnInfo Class
- ResultsTable Class
- Rotation Enum
- SectionType Enum
- WordGroupType Enum
- IDocumentTextProjection Interface
- ClassificationResult Class
- ExtractionResult Class
- ResultsDocument Class
- ResultsDocumentBounds Class
- ResultsDataPoint Class
- ResultsValue Class
- ResultsContentReference Class
- ResultsValueTokens Class
- ResultsDerivedField Class
- ResultsDataSource Enum
- ResultConstants Class
- SimpleFieldValue Class
- TableFieldValue Class
- DocumentGroup Class
- DocumentTaxonomy Class
- DocumentType Class
- Field Class
- FieldType Enum
- LanguageInfo Class
- MetadataEntry Class
- TextType Enum
- TypeField Class
- ITrackingActivity Interface
- ITrainableActivity Interface
- ITrainableClassifierActivity Interface
- ITrainableExtractorActivity Interface
- TrainableClassifierAsyncCodeActivity Class
- TrainableClassifierCodeActivity Class
- TrainableClassifierNativeActivity Class
- TrainableExtractorAsyncCodeActivity Class
- TrainableExtractorCodeActivity Class
- TrainableExtractorNativeActivity Class
- Document Understanding Digitizer
- Document Understanding ML
- Document Understanding OCR Local Server
- Document Understanding
- Release notes
- About the Document Understanding activity package
- Project compatibility
- Set PDF Password
- Merge PDFs
- Get PDF Page Count
- Extract PDF Text
- Extract PDF Images
- Extract PDF Page Range
- Extract Document Data
- Create Validation Task and Wait
- Wait for Validation Task and Resume
- Create Validation Task
- Classify Document
- Create Classification Validation Task
- Create Classification Validation Task and Wait
- Wait for Classification Validation Task and Resume
- Intelligent OCR
- Release notes
- About the IntelligentOCR activity package
- Project compatibility
- Configuring Authentication
- Load Taxonomy
- Digitize Document
- Classify Document Scope
- Keyword Based Classifier
- Document Understanding Project Classifier
- Intelligent Keyword Classifier
- Create Document Classification Action
- Wait For Document Classification Action And Resume
- Train Classifiers Scope
- Keyword Based Classifier Trainer
- Intelligent Keyword Classifier Trainer
- Data Extraction Scope
- Document Understanding Project Extractor
- RegEx Based Extractor
- Form Extractor
- Intelligent Form Extractor
- Present Validation Station
- Create Document Validation Action
- Wait For Document Validation Action And Resume
- Train Extractors Scope
- Export Extraction Results
- ML Services
- OCR
- OCR Contracts
- Release notes
- About the OCR Contracts
- Project compatibility
- IOCRActivity Interface
- OCRAsyncCodeActivity Class
- OCRCodeActivity Class
- OCRNativeActivity Class
- Character Class
- OCRResult Class
- Word Class
- FontStyles Enum
- OCRRotation Enum
- OCRCapabilities Class
- OCRScrapeBase Class
- OCRScrapeFactory Class
- ScrapeControlBase Class
- ScrapeEngineUsages Enum
- ScrapeEngineBase
- ScrapeEngineFactory Class
- ScrapeEngineProvider Class
- OmniPage
- PDF
- [Unlisted] Abbyy
- [Unlisted] Abbyy Embedded
OCRAsyncCodeActivity Class
Document Understanding Activities
Last updated Nov 21, 2024
OCRAsyncCodeActivity Class
An abstract class that must be implemented in order to construct an
AsyncCodeActivity
from the Workflow Foundation framework.
Methods
BeforeExecute(System.Activities.AsyncCodeActivityContext, System.AsyncCallback, object)
System.Collections.Generic.Dictionary<string, object>
- Overrides this method to compute and provide all the activity input arguments, other than theImage
argument, and returns the activity input arguments as a dictionary where the key is the argument name and the value is the argument value.Note: At design time, when no contexts are available, the method's parameters are null. In this case, the activity arguments can't be read, so you may want to provide default values for them.BeginExecute(System.Activities.AsyncCodeActivityContext, System.AsyncCallback, object)
System.IAsyncResult
- This method can be overridden to implement the activity code. It is called by the workflow runtime to execute the activity asynchronously. It also provides access to tracking, variables, and arguments.EndExecute(System.Activities.AsyncCodeActivityContext, System.IAsyncResult)
-System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Drawing.Rectangle, string>>
- This method can be overridden to notify the workflow runtime that the associated asynchronous activity operation has completed.OCRAsyncCodeActivity()
OnSuccess(System.Activities.AsyncCodeActivityContext, UiPath.OCR.Contracts.DataContracts.OCRResult)
void OnSuccess
- This method is called after computing the OCR result. It can be used to set output arguments or any other final operations.PerformOCRAsync(System.Drawing.Image, System.Collections.Generic.Dictionary<string, object>, System.Threading.CancellationToken)
System.Threading.Tasks.Task<UiPath.OCR.Contracts.DataContracts.OCRResult>
- Processes an image and returns the extracted text information. The options parameter is a dictionary of activity arguments having as key the argument name and as value the argument value.
Properties
ExtractWords
- Gets or sets if the words should be extracted.Image
System.Activities.InArgument<System.Drawing.Image>
- Image to be processed.Language
System.Activities.InArgument<string>
- The language used by the OCR engine to extract the string from the UI element. For the Google OCR engine, this field needs to contain the language file prefix, such as “ron” for Romanian, “ita” for Italian, and “fra” for French. You can find the supported language prefixes on this page.Output
System.Activities.OutArgument<UiPath.OCR.Contracts.OcrActivityResult>
- The activity output. Legacy, obsolete argument.Text
System.Activities.OutArgument<string>
- The textual value of the word.
[DisplayName("Sample OCRAsyncCodeActivity")]
internal class SampleOCRAsyncCodeActivity : OCRAsyncCodeActivity
{
[Browsable(true)]
public override InArgument<Image> Image { get; set; }
public InArgument<string> CustomInput { get; set; }
public OutArgument<string> CustomOutput { get; set; }
public override Task<OCRResult> PerformOCRAsync(Image image, Dictionary<string, object> options, CancellationToken ct)
{
string customInput = options[nameof(CustomInput)] as string;
string text = $"Text from {nameof(SampleOCRAsyncCodeActivity)} with custom input: {customInput}";
return Task.FromResult(OCRResultHelper.FromText(text));
}
protected override void OnSuccess(AsyncCodeActivityContext context, OCRResult result)
{
CustomOutput.Set(context, $"Custom output: '{result.Text}' has {result.Words.Length} words.");
}
protected override Dictionary<string, object> BeforeExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
{
return new Dictionary<string, object>
{
{ nameof(CustomInput), CustomInput.Get(context) }
};
}
}
[DisplayName("Sample OCRAsyncCodeActivity")]
internal class SampleOCRAsyncCodeActivity : OCRAsyncCodeActivity
{
[Browsable(true)]
public override InArgument<Image> Image { get; set; }
public InArgument<string> CustomInput { get; set; }
public OutArgument<string> CustomOutput { get; set; }
public override Task<OCRResult> PerformOCRAsync(Image image, Dictionary<string, object> options, CancellationToken ct)
{
string customInput = options[nameof(CustomInput)] as string;
string text = $"Text from {nameof(SampleOCRAsyncCodeActivity)} with custom input: {customInput}";
return Task.FromResult(OCRResultHelper.FromText(text));
}
protected override void OnSuccess(AsyncCodeActivityContext context, OCRResult result)
{
CustomOutput.Set(context, $"Custom output: '{result.Text}' has {result.Words.Length} words.");
}
protected override Dictionary<string, object> BeforeExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
{
return new Dictionary<string, object>
{
{ nameof(CustomInput), CustomInput.Get(context) }
};
}
}