Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

findtext doesn't return

Guest
May 20, 2016 May 20, 2016

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.

TOPICS
Acrobat SDK and JavaScript
704
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2016 Jun 10, 2016
LATEST

Anyone know why this is happening?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines