Copy link to clipboard
Copied
I've run into a problem where my call to FindText never returns when the text I'm looking for doesn't exist in the PDF. If the text does exist, it returns True in about 40 seconds; otherwise, I've let it run all night with no return. Here's a stripped down version of the code (I've verified that the problem occurs in this stripped down version).
_________________________________________________________________________________
Function fPDFContainsText(stPDFFullFilePath As String, stTextToSearchFor) As Boolean
Dim appPDF As Acrobat.AcroApp
Dim docAVPDF As Acrobat.acroavdoc
Dim fPDFOpen As Boolean
Set appPDF = New Acrobat.AcroApp ' create acrobat object
appPDF.Hide
Set docAVPDF = New Acrobat.acroavdoc ' create AVDoc object
fPDFOpen = docAVPDF.Open(stPDFFullFilePath, "") ' Open the PDF
If fPDFOpen = False Then Stop
fPDFContainsText = docAVPDF.FindText(stTextToSearchFor, 0, 0, 1) ' do the find
'I never get to here on some documents. Most work fine.
docAVPDF.Close False
Set docAVPDF = Nothing
appPDF.Exit
Set appPDF = Nothing
End Function
_____________________________________________________________________________________
Some background. I'm developing an application on Excel VBA to search an entire harddrive for PDF files, and for each one it finds, it calls the function above with the full path to the PDF file (first parameter), and the text I'm looking for (second parameter). If it finds the text, my function returns True, otherwise False.
The documents are very large. One, in particular, that is causing me problems is about 1100 pages long. I first suspected it might be a length problem, but it works on other documents that are even bigger, plus when I do a search for a word that exists only at the very end of the document, it finds it and returns True. The problem only seems to occur when the text doesn't exist anyplace in the document.
I've seen other similar topics on here, but none of the solutions worked in my case.
Copy link to clipboard
Copied
Anyone know why this is happening?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now