officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-findtext-x28-system-dot-string-x29.md
Searches for the specified text in the current document with default parameters.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public PdfTextSearchResults FindText(
string text
)
Public Function FindText(
text As String
) As PdfTextSearchResults
| Name | Type | Description |
|---|---|---|
| text | String |
A String value, specifying the text to find in the PDF.
|
| Type | Description |
|---|---|
| PdfTextSearchResults |
A PdfTextSearchResults object.
|
The overloaded FindText method uses the page coordinate system. Refer to the Coordinate Systems topic for more information.
The following code snippet counts all words in a document.
using DevExpress.Pdf;
// ...
private int WordCount(string filePath, string word) {
int count = 0;
try {
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
documentProcessor.LoadDocument(filePath);
while (documentProcessor.FindText(word).Status == PdfTextSearchStatus.Found) {
count++;
}
}
}
catch { }
return count;
}
Imports DevExpress.Pdf
' ...
Private Function WordCount(ByVal filePath As String, ByVal word As String) As Integer
Dim count As Integer = 0
Try
Using documentProcessor As New PdfDocumentProcessor()
documentProcessor.LoadDocument(filePath)
Do While documentProcessor.FindText(word).Status = PdfTextSearchStatus.Found
count += 1
Loop
End Using
Catch
End Try
Return count
End Function
The following code snippets (auto-collected from DevExpress Examples) contain references to the FindText(String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
pdf-document-api-add-link-to-page/CS/AddLinkToPage/Program.cs#L21
string linkText = "JBIG2 images";
PdfTextSearchResults linkSearchResults = pdfDocumentProcessor.FindText(linkText);
pdf-document-api-add-link-to-uri/CS/AddLinkToUri/Program.cs#L20
string linkText = "PDF Viewer";
PdfTextSearchResults linkSearchResults = processor.FindText(linkText);
pdf-document-api-add-link-to-page/VB/AddLinkToPage/Program.vb#L21
Dim linkText As String = "JBIG2 images"
Dim linkSearchResults As PdfTextSearchResults = processor.FindText(linkText)
pdf-document-api-add-link-to-uri/VB/AddLinkToUri/Program.vb#L19
Dim linkText As String = "PDF Viewer"
Dim linkSearchResults As PdfTextSearchResults = processor.FindText(linkText)
See Also