←Select platform

DocumentPageText Class


Contains the text characters and words found in a document page.

public class DocumentPageText 
Public Class DocumentPageText 
public [SerializableAttribute,  
   ref class DocumentPageText 
public class DocumentPageText implements Serializable 

The text of a document page can be read by using the DocumentPage.GetText method. The text characters found in the page will be set in the in Characters property of the returned DocumentPageText object.

The text words are created from the characters found in the document based on the IsEndOfWord returned by document parsing engine. Whenever an "end of word" is found, the last set of characters are grouped together and stored as an item in the Words list. This is not performed automatically, instead, you must call BuildWords to populate the Words list from the Characters.

The document page text can also be obtained as a simple string object through the Text property. This is not performed automatically and you must call BuildText to populate this property with the text value from Characters. Note that BuildText will also build the words by calls BuildWords first if this has not been done by the user first.

The FirstCharacterIndex and LastCharacterIndex of the DocumentWord object can be used to map the word back to the original characters in the Characters list. Similarly, you can use BuildTextWithMap to populate Text as well the TextMap list that can be used to map the text string all the way back to its part in the Characters list.

At any time, you can update the Characters list and call any of the methods above to re-generate Words, Text and TextMap. To clear the generated values, use ClearBuildData.

The text is parsed from the original document using either SVG or OCR technologies, for more information, refer to Parsing Text with the Document Library.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
public void DocumentPageTextExample() 
	var options = new LoadDocumentOptions(); 
	using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.doc"), options)) 
		// get text  
		var page = document.Pages[0]; 
		var pageText = page.GetText(); 
		if (pageText != null) 
			var text = pageText.Text; 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Document.Writer 
Imports Leadtools.Svg 
Imports Leadtools.Document 
Imports Leadtools.Caching 
Imports Leadtools.Annotations.Engine 
Imports Leadtools.Barcode 
Imports Leadtools.Ocr 
Imports LeadtoolsDocumentExamples.LeadtoolsExamples.Common 
Imports Leadtools.Document.Converter 
Public Shared Sub DocumentPageTextExample() 
   Dim options As New LoadDocumentOptions() 
   Using document As LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.doc"), options) 
      ' get text  
      Dim page As Leadtools.Document.DocumentPage = document.Pages(0) 
      Dim pageText As DocumentPageText = page.GetText() 
      If Not IsNothing(pageText) Then 
         Dim text As String = pageText.Text 
      End If 
   End Using 
End Sub 
Target Platforms
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly

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