Manages the text options of the document.
[DataContractAttribute()]public class DocumentText
<DataContractAttribute()>Public Class DocumentText
public [DataContractAttribute]ref class DocumentText
public class DocumentText implements SerializableDocumentText manages the text of the document and can be accessed through the Text property of Document.
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 Documents Library.
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms.DocumentWriters;using Leadtools.Svg;using Leadtools.Documents;using Leadtools.Caching;using Leadtools.Annotations.Core;using Leadtools.Forms.Ocr;using Leadtools.Barcode;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.Advantage, false);var rasterCodecs = new RasterCodecs();var documentWriter = new DocumentWriter();ocrEngine.Startup(rasterCodecs, documentWriter, null, LEAD_VARS.OcrAdvantageRuntimeDir);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!");}}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Forms.DocumentWritersImports Leadtools.SvgImports Leadtools.DocumentsImports Leadtools.CachingImports Leadtools.Annotations.CoreImports Leadtools.BarcodeImports Leadtools.Forms.Ocr<TestMethod()>Public Shared Sub DocumentTextExample()Dim options As New LoadDocumentOptions()Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.tif"), options)'for the TIF file we need an OCR engineDim ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)Dim rasterCodecs As New RasterCodecs()Dim documentWriter As New DocumentWriter()ocrEngine.Startup(rasterCodecs, documentWriter, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)document.Text.OcrEngine = ocrEngine' get textDim page As Leadtools.Documents.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 Sub
|
Products |
Support |
Feedback: DocumentText Class - Leadtools.Documents |
Introduction |
Help Version 19.0.2017.3.22
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.