Knowledge Base - Search in whole pdf file (Windows)

Knowledge Base - Search in whole pdf file (Windows)

This article shows how to search a string in a whole pdf file.

With this method you can use a PDFDoc instance to search a word in a whole pdf file and store/menage results.

 

public void customSearch(PDFDoc doc, String search)
{
bool caseSensitive = false;
bool wholeWord = false;

for (int i = 0; i < doc.PageCount; i++)
{
PDFPage page = doc.GetPage(i);
page.ObjsStart();

// find in page
PDFFinder finder = page.GetFinder(search, caseSensitive, wholeWord);

// manage each search term contained in this page
for (int c = 0; c < finder.GetCount(); c++)
{
// start position
int firstCharPos = finder.GetFirstChar(c);

System.Diagnostics.Debug.WriteLine("PAGE:" + i);
System.Diagnostics.Debug.WriteLine("Position:" + firstCharPos);

// do custom actions
}
// close page
page.Close();
}
}
Applies To

RadaeePDF SDK for Windows 10

Details

Created : 2018-07-18 10:49:16, Last Modified : 2018-07-18 10:51:17