Manages the text options of the document.
[DataContractAttribute()]public class DocumentText
<DataContractAttribute()>Public Class DocumentText
public [DataContractAttribute]ref class DocumentText
public class DocumentText implements Serializable
DocumentText manages the text of the document and can be accessed through the Text property of LEADDocument.
The text of a document page can be extracted using the DocumentPage.GetText method. This will return a DocumentPageText instance that contains the text characters found in the page with location and size properties. Furthermore, DocumentPageText supports building the words or the text as string for easy processing.
The framework can use either SVG or OCR technologies to extract the text data. Which method to use can be controlled using the TextExtractionMode property.
For more information, refer to Parsing Text with the Document Library.
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Svg;using LeadtoolsExamples.Common;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public static void DocumentTextExample(){var options = new LoadDocumentOptions();using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.tif"), options)){//for the TIF file we need an OCR enginevar ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);var rasterCodecs = new RasterCodecs();var documentWriter = new DocumentWriter();ocrEngine.Startup(rasterCodecs, documentWriter, null, LEAD_VARS.OcrLEADRuntimeDir);document.Text.OcrEngine = ocrEngine;// get textvar page = document.Pages[0];var pageText = page.GetText();if (pageText != null){pageText.BuildText();var text = pageText.Text;Console.WriteLine(text);}else{Console.WriteLine("Failed!");}}}static class LEAD_VARS{public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Document.WriterImports Leadtools.SvgImports Leadtools.DocumentImports Leadtools.CachingImports Leadtools.Annotations.EngineImports Leadtools.BarcodeImports Leadtools.OcrImports LeadtoolsDocumentExamples.LeadtoolsExamples.CommonImports Leadtools.Document.ConverterPublic Shared Sub DocumentTextExample()Dim options As New LoadDocumentOptions()Using document As Leadtools.Document.LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.tif"), options)'for the TIF file we need an OCR engineDim ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, False)Dim rasterCodecs As New RasterCodecs()Dim documentWriter As New DocumentWriter()ocrEngine.Startup(rasterCodecs, documentWriter, Nothing, LEAD_VARS.OcrLEADRuntimeDir)document.Text.OcrEngine = ocrEngine' get textDim page As Leadtools.Document.DocumentPage = document.Pages(0)Dim pageText As DocumentPageText = page.GetText()If Not pageText Is Nothing ThenpageText.BuildText()Dim text As String = pageText.TextConsole.WriteLine(text)ElseConsole.WriteLine("Failed!")End IfEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
