Gets the text content of this page.
public DocumentPageText GetText() Public Function GetText() As DocumentPageText public:DocumentPageText^ GetText()
public DocumentPageText getText() The text content of this DocumentPage as a DocumentPageText object.
GetText is used to parse the text content of a page. All document types support this method and internally will use the LEADTOOLS SVG or OCR engines to obtain the text from the document.
SetText is used to replace the text content of the page. IsTextModified is used to as flag that indicates that the text of this page has been replaced by the user.
This method works as follows (the "item" is the text content):
If an item was found in the cache, it is returned right away. This is available if the document was created using the cache system. and Document.CacheOptions contains DocumentCacheOptions.PageText.
The value of DocumentImages.IsSvgSupported and DocumentText.TextExtractionMode will determine if the text is parsed from the page using LEADTOOLS SVG or OCR engines.
If SVG is supported, then GetSvg is called and the text is parsed from the SVG content directly without the use of OCR.
Otherwise, and if OCR is supported, then GetImage is called and the text is parsed from the raster image using OCR.
If this document uses the cache system (Document.HasCache is true), then the DocumentPageText object is saved to the cache before it is returned. Next time this method is called, the text will be returned from the cache directly without parsing it again.
When the value of DocumentText.AutoParseLinks is true and the page text is first obtained using GetText, then the document will attempt to also parse the text for links based on the regular expressions stored in LinkPatterns.
Note that if SetText has been previously called with a null object for the text parameter, then this method will return null as well.
In all cases, the returned DocumentPageText object is not used by this Document after it has been returned.
The LEADTOOLS Document Viewer uses this method to obtain the text used with all text operations such Find, Select Text and Text Review annotations objects.
For more information, refer to Parsing Text with the Documents Library.
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms.DocumentWriters;using Leadtools.Svg;using LeadtoolsExamples.Common;using Leadtools.Documents;using Leadtools.Caching;using Leadtools.Annotations.Core;using Leadtools.Forms.Ocr;using Leadtools.Barcode;public static void DocumentPageGetTextExample(){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!");}}}static class LEAD_VARS{public const string OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Forms.DocumentWritersImports Leadtools.SvgImports Leadtools.DocumentsImports Leadtools.CachingImports Leadtools.Annotations.CoreImports Leadtools.BarcodeImports Leadtools.Forms.OcrImports LeadtoolsDocumentsExamples.LeadtoolsExamples.Common'Imports LeadtoolsDocumentsExamples.LeadtoolsExamples.CommonPublic Shared Sub DocumentPageGetTextExample()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 SubPublic NotInheritable Class LEAD_VARSPublic Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"End Class
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
