Frequently Asked Question
Search in whole pdf file (Windows)
Last Updated 11 months ago
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(); } }