My problem is widely known and frequenty posted, for instance:
"Can anyone help me to open and search for a specific text string in a PDF document, return a true or false indicator (and nothing else)?"
The answers mostly refer to and include
Set gApp = CreateObject("AcroExch.App")
which, as I understand, works only with a certain level of Adobe Acrobat being installed.
My question now:
I want to give this type of functionality (via an MSAccess Form, i.e. populate a ComboBox with PDF filenames which answer YES to certain text occurences) to - say 20 - users in my company who have Adobe Reader 9.1 installed and not more.
Having this number of Adobe Acrobat licenses would be a heavy overkill which I just can't afford.
Any sugestions? many thanks in advance.
I am still learning this and right now, am searching for text between the words "DATE" and "RE" in documents, to capture the report date which would appear as
DATE: January 20, 2010
RE: .....
I want to pick out the "January 20, 2010" from the PDF - though right now the code just searches for WORDS and does not pick up punctuation. I have to figure out the punctuation next. This code runs in Excel right now and I have specified the path to the PDF file previosly in the string variable gPDFPath
This is an extract of the code I am using. I write the text I find out to a file. You could modify it to just report your boolean instead of writing to the file.
Set gApp = CreateObject("AcroExch.App")
gApp.Hide
'Set PDDpc object
Set gPDDoc = CreateObject("AcroExch.PDDoc")
' open the PDF
If gPDDoc.Open(gPDFPath) Then 'success
Open strfileout For Append As #ioutfile
Set jso = gPDDoc.GetJSObject
bleFound = False
iNumPages = gPDDoc.GetNumPages
If Not jso Is Nothing Then
For j = 0 To iNumPages - 1
count = jso.getPageNumWords(j) 'if argument is 0, searches current page, else searches all
lMarkLeft = 0
lMarkRight = 0
For i = 0 To count - 1
word = jso.getPageNthWord(j, i)
If LCase(word) = "date" Then lMarkLeft = i + 1
If LCase(word) = "re" Then lMarkRight = i - 1
If lMarkLeft > 0 And lMarkRight > 0 Then
bleFound = True
For m = lMarkLeft To lMarkRight
If bleFound = True Then
If m < lMarkRight Then
Print #ioutfile, jso.getPageNthWord(0, m); " ";
Else
Print #ioutfile, jso.getPageNthWord(0, m); ",";
End If
End If
Next 'm
bleFound = False
lMarkLeft = 0
lMarkRight = 0
'print information between "date:" and "re:" to file, as this is the report date
End If
Next i
.....