Indicates where to start finding text within the bounds of a Find Text operation.
public DocumentViewerFindTextStart Start { get; set; }
An enum value from DocumentViewerFindTextStart that indicates where the text search should start. The default value is DocumentViewerFindTextStart.BeginPosition, which creates one search starting from BeginPosition and stopping at EndPosition.
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 the BeginPosition.
The DocumentViewerFindTextStart enum allows the operation to start inside or after the selection bounds (which is useful when paired with SelectFirstResult) or to start at a unique position with ManualStartPosition.
Although Start can be a value other than BeginPosition, the search can still be effectively run from BeginPosition to EndPosition if: - DocumentViewerFindTextStart.InSelection or DocumentViewerFindTextStart.AfterSelection is used and there is no selected text or the selected text is before the BeginPosition
Otherwise, Start is likely to cause two internal searches:
For more information, refer to DocumentViewerText.Find.
History
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 necessarytext.AutoGetText = true;// We will find all matches of "LEAD", ignoring the casevar options = new DocumentViewerFindText();// The textoptions.Text = "LEAD";// Ignore caseoptions.MatchCase = false;// Any word that contains the phraseoptions.WholeWordsOnly = false;// Find all results in the bounds, not just the firstoptions.FindAll = true;// Highlight the results in the Viewoptions.RenderResults = true;// Optionally change the highlight color//DocumentViewerText.FoundTextBrush = new SolidBrush(Color.FromArgb(52, Color.Brown));// Set the boundsbool 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 pagevar 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);elseoptions.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();// Searchvar results = text.Find(options);int resultsCount = results != null ? results.Count : 0;if (resultsCount > 0)Console.WriteLine(string.Format("Found {0} results", resultsCount));elseConsole.WriteLine("No matches found.");