Skip to content

Commit 0bf6211

Browse files
authored
Merge pull request #2377 from syncfusion-content/Multiline_FindText_UG
Added UG changes for Multi-line text search support in FindText API f…
2 parents e44fb9c + 013838d commit 0bf6211

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Document-Processing/PDF/PDF-Viewer/wpf/Searching-Text.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,43 @@ private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
157157
{% endhighlight %}
158158
{% endtabs %}
159159

160+
### Find and get the bounds of the list of text on multiple lines
161+
162+
The [FindText](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.PdfViewer.PdfViewerControl.html) method provides an overload with an `enableMultilineSearch` parameter that allows detection of matches spanning line breaks or multiple pages. When enabled, results are returned as line‑based TextSearchResult entries grouped by page, including the matched text and corresponding RectangleF bounds. The default value of enableMultilineSearch is false.
163+
164+
{% tabs %}
165+
{% highlight c# %}
166+
167+
private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
168+
{
169+
//Get the occurrences of the target text and location.
170+
Dictionary<int, List<TextSearchResult>> searchResult = new Dictionary<int, List<TextSearchResult>>();
171+
//List of text need to be found
172+
List<string> findText = new List<string>() {"Find the text that spans across multiple lines and pages"};
173+
174+
//Enable multiline search to detect line and page breaks and return line-wise results.
175+
//Return true, if the given text is found across lines/pages
176+
bool isMatchFound = pdfViewer.FindText(findText, out searchResult, true);
177+
if (isMatchFound)
178+
{
179+
foreach (var Index in searchResult)
180+
{
181+
int pageIndex = Index.Key;
182+
List<TextSearchResult> results = Index.Value;
183+
foreach (TextSearchResult result in results)
184+
{
185+
//The Bounds contains the line-wise rectangle for the matched text.
186+
RectangleF bounds = result.Bounds;
187+
//The Text property contains the matched text for this line.
188+
string matchedText = result.Text;
189+
}
190+
}
191+
}
192+
}
193+
194+
{% endhighlight %}
195+
{% endtabs %}
196+
160197
### Find and get the bounds of the list of text on the desired page
161198

162199
The [FindText](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.PdfViewer.PdfViewerControl.html#Syncfusion_Windows_PdfViewer_PdfViewerControl_FindText_System_Collections_Generic_List_System_String__System_Int32_System_Collections_Generic_List_Syncfusion_Pdf_Parsing_MatchedItem___) method takes the input argument as the list of text to be found along with the desired page index and provides the list of [MatchedItem](https://help.syncfusion.com/cr/wpf/Syncfusion.Pdf.Parsing.MatchedItem.html), which contains the matched text, and its rectangular coordinates(bounds). The below code snippet illustrates how to get the bounds of the text from the matched item:

0 commit comments

Comments
 (0)