←Select platform

ManualStartPosition Property

Summary

Indicates where to start finding text when the value of Start is DocumentViewerFindTextStart.ManualPosition.

Syntax
C#
C++/CLI
public DocumentViewerTextPosition ManualStartPosition { get; set; } 
public:  
   property DocumentViewerTextPosition^ ManualStartPosition 
   { 
      DocumentViewerTextPosition^ get() 
      void set(DocumentViewerTextPosition^ value) 
   } 

Property Value

A DocumentViewerTextPosition object indicating the page number and index of the start of the search. The default value is null, which will cause Start to behave as if it were set to DocumentViewerFindTextStart.BeginPosition.

Remarks

BeginPosition and EndPosition set the beginning and end of the search bounds and the direction of the search, but Start provides the ability to start finding text at a position other than BeginPosition. This can cause the order of results to change, which is useful for SelectFirstResult.

When Start is set to DocumentViewerFindTextStart.ManualPosition, ManualStartPosition is used as the starting position for DocumentViewerText.Find, within the bounds of BeginPosition and EndPosition. If ManualStartPosition is null, the search defaults to BeginPosition as the starting position.

Use of ManualStartPosition is likely to cause two internal searches:

  1. Search from the start to EndPosition.
  2. If starting from (1) was not BeginPosition, and FindAll or Loop is true, search from BeginPosition to start – 1.

A -1 can be used as the value of DocumentViewerTextPosition.CharacterIndex to indicate the end of a page. However, if a value other than 0 or -1 is used, DocumentViewerText.Find will check that the DocumentPageText exists before starting the search. If the text for the page does not exist, the find text operation will fail immediately and return no results.

For more information, refer to DocumentViewerText.Find.

History

19.0.0.49
Added
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; 
 
// Make sure we get the page text if necessary 
text.AutoGetText = true; 
 
// We will find all matches of "LEAD", ignoring the case 
var options = new DocumentViewerFindText(); 
 
// The text 
options.Text = "LEAD"; 
// Ignore case 
options.MatchCase = false; 
// Any word that contains the phrase 
options.WholeWordsOnly = false; 
 
// Find all results in the bounds, not just the first 
options.FindAll = true; 
 
// Highlight the results in the View 
options.RenderResults = true; 
// Optionally change the highlight color 
//DocumentViewerText.FoundTextBrush = new SolidBrush(Color.FromArgb(52, Color.Brown)); 
 
// Set the bounds 
bool isFindingNext = true; 
// We set the bounds as the whole document, but below we can specify to start wherever text is selected 
// or at the current page 
var topOfFirstPage = DocumentViewerTextPosition.CreateBeginOfPage(1); 
var bottomOfLastPage = DocumentViewerTextPosition.CreateEndOfPage(_documentViewer.PageCount); 
if (isFindingNext) 
{ 
   // Make the beginning bound "higher up" the page so we search "down" the page. 
   options.BeginPosition = topOfFirstPage; 
   options.EndPosition = bottomOfLastPage; 
} 
else 
{ 
   // Make the beginning bound "lower down" the page so we search "up" the page. 
   options.BeginPosition = bottomOfLastPage; 
   options.EndPosition = topOfFirstPage; 
} 
 
// Select the first result in the View (automatically scrolls View also) 
options.SelectFirstResult = true; 
 
if (text.HasAnySelectedText) 
{ 
   // Setting this value to AfterSelection allows us to search forward from the selection, so multiple 
   // uses of this same options object will cycle us through all the matches! 
   // (If no selected text actually exists, search will default to beginPosition.) 
   options.Start = DocumentViewerFindTextStart.AfterSelection; 
} 
else 
{ 
   // We could start at the begin position, but it makes more UI sense to start from the user's current page. 
   // Search will loop back around to the begin position - this just changes the starting point and order of results. 
   options.Start = DocumentViewerFindTextStart.ManualPosition; 
   if (isFindingNext) 
      options.ManualStartPosition = DocumentViewerTextPosition.CreateBeginOfPage(_documentViewer.CurrentPageNumber); 
   else 
      options.ManualStartPosition = DocumentViewerTextPosition.CreateEndOfPage(_documentViewer.CurrentPageNumber); 
} 
 
// If we were just looking for the first match, we could use "Loop" to loop around 
// if we found nothing between the start position and the end bound. 
//options.Loop = true; 
 
// You will likely want to clear the previous highlighted results 
// on the screen so only our new results will show. 
text.ClearRenderedFoundText(); 
 
// Search 
var results = text.Find(options); 
int resultsCount = results != null ? results.Count : 0; 
 
if (resultsCount > 0) 
   Console.WriteLine(string.Format("Found {0} results", resultsCount)); 
else 
   Console.WriteLine("No matches found."); 
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.