Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfDocumentProcessor.FindText(String) Method

Searches for the specified text in the current document with default parameters.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v24.2.dll

NuGet Package: DevExpress.Document.Processor

#Declaration

public PdfTextSearchResults FindText(
    string text
)

#Parameters

Name Type Description
text String

A String value, specifying the text to find in the PDF.

#Returns

Type Description
PdfTextSearchResults

A PdfTextSearchResults object.

#Remarks

The overloaded FindText method uses the page coordinate system. Refer to the Coordinate Systems topic for more information.

The code sample below counts all words in a document.

View Example

using DevExpress.Pdf;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using System.IO;
using System.Text;
using System.Windows.Forms;
// ...
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;
}
See Also