Error processing SSI file
LEADTOOLS Leadtools.Documents (Leadtools.Documents assembly)

Show in webframe

ClipText Method






The area to clone. This value is in document coordinates.
Creates a new DocumentPageText from a portion of this text data.
Syntax
public DocumentPageText ClipText( 
   LeadRectD bounds
)
'Declaration
 
Public Function ClipText( _
   ByVal bounds As LeadRectD _
) As DocumentPageText
'Usage
 
Dim instance As DocumentPageText
Dim bounds As LeadRectD
Dim value As DocumentPageText
 
value = instance.ClipText(bounds)
public DocumentPageText clipText(LeadRectD bounds)
            
public:
DocumentPageText^ ClipText( 
   LeadRectD bounds
) 

Parameters

bounds
The area to clone. This value is in document coordinates.

Return Value

New DocumentPageText that contains only the characters that are included in bounds.
Remarks

Use this method to create a copy of DocumentPageText that contains only the characters that intersect with a specified rectangle. For example, if your application contains functionality where the user can select a portion of the page using rubber band to extract text from, then you can use ClipText on the page object to return a new object that can be used with BuildWords or BuildText to parse only the words and text of the area.

ClipText works by checking the value of DocumentCharacter.Bounds of each item in Characters by intersecting with bounds. If the value intersects, then it is added to the Characters list of the new object.

If the value of bounds is empty (IsEmpty), then this method returns an exact copy of this DocumentPageText.

bounds must be in document coordinates. Refer to Documents Library Coordinate System for more information.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools.Svg
Imports Leadtools.Documents
Imports Leadtools.Caching
Imports Leadtools.Annotations.Core
Imports Leadtools.Barcode
Imports Leadtools.Forms.Ocr

<TestMethod()> _
Public Sub DocumentPageTextClipTextExample()
   Dim options As New LoadDocumentOptions()
   options.UseCache = False
   Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.doc"), options)
      Dim clipPixels As LeadRect = LeadRect.FromLTRB(1337, 300, 1545, 347)
      Dim clipDocument As LeadRectD = document.RectToDocument(clipPixels)

      ' get text 
      Dim page As Leadtools.Documents.DocumentPage = document.Pages(0)
      Dim pageText As DocumentPageText = page.GetText().ClipText(clipDocument)
      If Not pageText Is Nothing Then
         pageText.BuildText()
         Dim text As String = pageText.Text

         Console.WriteLine(text)
      Else
         Console.WriteLine("Failed!")
      End If
   End Using
End Sub
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;

[TestMethod]
public void DocumentPageTextClipTextExample()
{
   var options = new LoadDocumentOptions();
   options.UseCache = false;
   using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.doc"), options))
   {
      LeadRect clipPixels = LeadRect.FromLTRB(1337, 300, 1545, 347);
      LeadRectD clipDocument = document.RectToDocument(clipPixels);

      // get text 
      var page = document.Pages[0];            
      var pageText = page.GetText().ClipText(clipDocument);
      if (pageText != null)
      {
         pageText.BuildText();
         var text = pageText.Text;

         Console.WriteLine(text);
      }
      else
      {
         Console.WriteLine("Failed!");
      }
   }
}
Requirements

Target Platforms

See Also

Reference

DocumentPageText Class
DocumentPageText Members

Error processing SSI file
   Leadtools.Documents requires a Document or Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features