Here's a simple AutoIt program that will let you search a directory of pdf files, (including recursive), for specific text at the end it will output a list of files that had matches - started off based on the code above.
Nothing fancy but it might get you started.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Res_File_Add=pdftotext.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Include lots of constants for GUI creation
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <RFLTA.au3> ; Recursive filelist function
; If pdftotext.exe doesn't exist then extract it from within the SearchPDF executable
If Not FileExists('pdftotext.exe') Then
FileInstall('pdftotext.exe', '.\pdftotext.exe')
EndIf
; Global variables: inifile
Global $inifile = StringLeft(@ScriptName, StringLen(@ScriptName) - 4) & '.ini'
; Initial search directory = users Documents
$current = @MyDocumentsDir
$_text = ''
_GetIni() ; Get previous directory & search from inifile
; Simple GUI interface
#Region ### START Koda GUI section ###
$Form1_1 = GUICreate("SearchPDF", 354, 376) ; GUI window name/size
$Input1 = GUICtrlCreateInput("", 7, 65, 250, 21) ; Search text input field
GUICtrlSetData($Input1, $_text) ; Set with previous data if it exists
$Input2 = GUICtrlCreateInput("", 8, 10, 250, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ; Search dir display field
GUICtrlSetData($Input2, $current) ; Set with previous data if it exists
$Button1 = GUICtrlCreateButton("Path", 270, 7, 75, 25) ; Path select button
$Button2 = GUICtrlCreateButton("Exit", 136, 339, 75, 25) ; Exit button
$Button3 = GUICtrlCreateButton("Search", 272, 65, 75, 25) ; Search button
$Checkbox1 = GUICtrlCreateCheckbox("Recurse", 272, 40, 65, 17) ; Recurse checkbox
$Edit1 = GUICtrlCreateEdit("", 8, 100, 337, 229) ; Edit control for output, will let you copy text, (and edit it)
GUISetState(@SW_SHOW) ; Show the GUI
#EndRegion ### END Koda GUI section ###
While 1 ; Wait for something to happen
$nMsg = GUIGetMsg() ; Get any messages from the interface
Switch $nMsg
Case $Button1 ; Path button pressed
$temp = FileSelectFolder('Folder to monitor:', '', 4)
If @error <> 1 Then $current = $temp
GUICtrlSetData($Input2, $current) ; Change input field to reflect chosen path
Case $GUI_EVENT_CLOSE, $Button2 ; GUI closed/Exit pressed: Write out current path/search text
IniWrite($inifile, 'General', 'Path', $current)
IniWrite($inifile, 'General', 'Search', $_text)
Exit
Case $Button3 ; Search pressed
If (GUICtrlRead($Checkbox1) = $GUI_CHECKED) Then ; Read state of Recurse checkbox and set flag
$_recurse = 1
Else
$_recurse = 0
EndIf
$_text = GUICtrlRead($Input1) ; Read search text, if empty pop up a message
If $_text = '' Then
MsgBox(48, 'SearchPDF', 'No search text entered')
ContinueCase
EndIf
$_pdfFiles = _RecFileListToArray($current, '*.pdf', 1, $_recurse, 0, 2) ; Call RFLTA to list all .pdf files
If Not IsArray($_pdfFiles) Or $_pdfFiles[0] = 0 Then ; If none found, pop up a message
MsgBox(48, 'SearchPDF', 'No PDF files found')
ContinueCase
EndIf
Search($_pdfFiles, $_text) ; Call Search function with array of pdf files and search text
Case Else
EndSwitch
WEnd
Func Search($files, $text) ; Arguments passed: Array containing PDF path\filenames and text to search for
Local $_tempFile = @TempDir & '\tempPDF.txt', $output = '' ; Local variables: temporary txt file and output
For $i = 1 To $files[0] ; First array element [0] contains number of files
$_RunWait = '"' & $files[$i] & '" ' & $_tempFile ; Compose command for conversion
RunWait(@comspec & ' /c pdftotext.exe ' & $_RunWait, '.', @SW_HIDE) ; Execute command for conversion with hidden CLI
$filecontents = FileRead($_tempFile) ; Read converted PDF file into variable
$textInFile = StringInStr($filecontents, $text) ; Look for search text
If $textInFile > 0 Then ; If it exists add filename to output list
$output &= $files[$i] & @CRLF
EndIf
FileDelete($_tempFile) ; Delete temporary txt file ready for next conversion
Next
If $output = '' Then $output = 'No files matched'
GUICtrlSetData($Edit1, $output) ; Write the results into the edit control
EndFunc ;==>Search
Func _GetIni() ; Reads data from ini file if it exists
If FileExists($inifile) Then
$current = IniRead($inifile, 'General', 'Path', @MyDocumentsDir)
$_text = IniRead($inifile, 'General', 'Search', '')
EndIf
EndFunc
pdftotext.exe is contained within SearchPDF.exe as a resource, it'll be extracted out if necessary. Previous path and search are written to an ini file on exit to be used next time it's run.
Seems to work OK but no great bug finding was performed, no error trapping either.
EDIT: Cleaned it up a bit, (laugh if you like), now outputs to edit control so you can copy results, added lots of comments because mouser likes that kind of thing.
EDIT2: Tells you if no matches are found.
Anyway, I'm stopping there - you could add a progressbar, some way to cancel, better output (eg. line numbers within the file, no text within file, etc), etc.