←Select platform

Text Property

Summary

Manages the text operations in this document viewer.

Syntax
C#
C++/CLI
public DocumentViewerText Text { get; } 
public:  
   property DocumentViewerText^ Text 
   { 
      DocumentViewerText^ get() 
   } 

Property Value

The DocumentViewerText object that manages the text operations in this document viewer.

Remarks

This class manages the text operations of the current LEADDocument set in the document viewer. The text is treated as a read-only option and cannot be changed. The operations that can be performed includes selecting characters, words or lines using the mouse or touch, highlighting the selected text of the pages, performing free text search in the document using "find", "find next" and "find previous" and exporting the text as a simple string or to the clipboard.

Refer to DocumentViewerText for more information.

Example
C#
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Document; 
using Leadtools.Document.Viewer; 
using Leadtools.Codecs; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
 
 
var text = _documentViewer.Text; 
 
// First check if we have text for this page 
var pageNumber = _documentViewer.CurrentPageNumber; 
if (!text.HasDocumentPageText(pageNumber)) 
{ 
   // Get the text 
   text.GetDocumentPageText(pageNumber); 
 
   // Show it 
   var value = text.ExportText(pageNumber); 
   Console.WriteLine(value); 
} 
 
// Get the current document 
var document = _documentViewer.Document; 
// Get the page and the current view item 
var page = document.Pages[pageNumber - 1]; 
// Create a rectangle that is the first half of the page 
var bounds = LeadRectD.Create(0, 0, page.Size.Width, page.Size.Height / 2); 
// SelectText requires the rectangle to be in control pixel coordinates, so convert. First to pixels ... 
bounds = document.RectToPixels(bounds).ToLeadRectD(); 
// And then using the image viewer in the view to control. The item is the one at page number - 1 
var imageViewer = _documentViewer.View.ImageViewer; 
bounds = imageViewer.ConvertRect(imageViewer.Items[pageNumber - 1], ImageViewerCoordinateType.Image, ImageViewerCoordinateType.Control, bounds); 
// Select it, all lines 
text.SelectText(bounds.ToLeadRect(), DocumentViewerSelectTextMode.Line); 
 
// Now, check if we have any text selected 
if (text.HasSelectedText(pageNumber)) 
{ 
   // yes, show it 
   var value = text.GetSelectedText(pageNumber); 
   Console.WriteLine(value); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Viewer.WinForms Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.