AcroExch.AVDoc.FindText()

Ask a Question related to Adobe Acrobat SDK, Design and Development.

  1. #1

    Default AcroExch.AVDoc.FindText()

    Hi, there
    Does anyone have any experience of the FindText() function? I was hoping to use it together with acrApp.MenuItemExecute "NewBookmark" to create a set of standard bookmarks. The API documentation claims that the function "Finds the specified text, scrolls so that it is visible, and highlights it" and it returns "True if the text was found, False if it was not." From my experience, though, it always returns True, and certainly doesn't scroll to the text or highlight it. In fact, all it seems to do is insert the find text in the application's search field.
    Or am I doing summit wrong?

    Dim acrApp, acrAVDoc
    Set acrApp = CreateObject("AcroExch.App")
    Set acrAVDoc = CreateObject("AcroExch.AVDoc")
    acrApp.Show
    If acrAVDoc.Open(MY_FILE, "") Then
    acrAVDoc.FindText MY_TEXT, False, True, True
    etc...

    thanks

    jON

    - Adobe Acrobat 6.0
    - MS Office 2003
    - MS Windows XP Professional SP2
    Jon_Pyne@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. Printing document using AVDoc.PrintPages
      Hello, I have used AVDoc.PrintPages to print PDF pages, it worked all fine until I upgraded from Adobe Pro version 7 to Adobe Std version 9. When...
    2. Duplicate AVDoc for the same PDDoc
      Is it possible to duplicate an AVDoc and show it in an external Window? According to API Reference, „“Starting with Acrobat 7.0, it is possible to...
    3. Help with AcroExch.PDBookmark in VBA
      I'm using the following subroutine in a Microsoft Access VBA module, which successfully opens a PDF document that is on the local hard drive: ...
    4. How to get the selected text in the FindText method? (In C#)
      Hello, I need to get the selected text to make several checks using the method GetBoundingRect of the class AcroPDTextSelectClass. I have this...
    5. findtext immediately following the 'search' text
      I have this code: Dim avDoc As New Acrobat.AcroAVDoc Dim avPV As Acrobat.AcroAVPageView ...
  3. #2

    Default Re: AcroExch.AVDoc.FindText()

    Mmmh,

    is my SDK (5.1) to old?

    I would write:

    $Ok = acrAVDoc.FindText MY_TEXT, 0, 1, 1
    if $Ok = 1 then msgbox("Found")

    MfG. Reinhard
    Reinhard_Franke@adobeforums.com Guest

  4. #3

    Default Re: AcroExch.AVDoc.FindText()

    Mmmh,

    I get true or false, but bothersome is, that when OK = false a msgbox appears and says "couldn't find".

    You may play a little bit with that and perhabs use JSO for find/highlite in order to avoid that msgbox.

    best regards, Reinhard

    TestFind.vbs
    ---------------------------

    Dim acrApp, acrAVDoc
    Set acrApp = CreateObject("AcroExch.App")
    Set acrAVDoc = CreateObject("AcroExch.AVDoc")
    acrApp.Show
    If acrAVDoc.Open ("c:\Test.pdf","") Then
    Ok = acrAVDoc.FindText("SomeWhat", 0, 1, 1)
    msgbox(Ok)
    end if

    set acrAvDoc = Nothing
    set acrApp = Nothing
    Reinhard_Franke@adobeforums.com Guest

  5. #4

    Default Re: AcroExch.AVDoc.FindText()

    The return value is always True (or -1), whether the text is in the document or not. I've kind of given up on that working by itself, but am trying to use the fact that it plugs the string into a search and executes it. Where I am at now is...

    acrAVDoc.FindText MY_TEXT, False, True, False = Now Do
    DoEvents
    Loop Until Now > i + 0.00001
    acrApp.MenuItemExecute "SearchSubmenu, FindAgain" = Now Do
    DoEvents
    Loop Until Now > i + 0.00001
    acrApp.MenuItemExecute "NewBookmark"
    acrPDBookmark.GetByTitle acrPDDoc, "Untitled"
    acrPDBookmark.SetTitle MY_TEXT

    This is working as of now, but the whole system seems incredibly unpredictable. If I tweak something, it seems to break everything. Sometimes I get the search pane on the right; sometimes I don't.
    Jon_Pyne@adobeforums.com Guest

  6. #5

    Default Re: AcroExch.AVDoc.FindText()

    As I understood from somewhere, JSO is only good for searching for one word.
    Jon_Pyne@adobeforums.com Guest

  7. #6

    Default Re: AcroExch.AVDoc.FindText()

    For me (AAv5) it works well.

    Perhaps you have a look at this JS from my libary:

    Loops through pages to find all word occurrence
    //Paste this into your console, select all the text and hit ENTER on your keyboard
    var wf = "Sales" //word to find
    for (var i=0;i<this.numPages;i++){ for (var j=0;j<this.getPageNumWords(i);j++){ if (this.getPageNthWord({nPage:i,nWord:j}).toString() == wf){ app.alert("Found on Page: " +(i+1)) }}}

    But it works realy only on one word (like "Sales",
    but not: "Net Sales")

    If that is already enough, we can use it with a vbs

    Br, Reinhard
    Reinhard_Franke@adobeforums.com Guest

  8. #7

    Default Re: AcroExch.AVDoc.FindText()

    Thanks for your input Reinhard, but I need to search for a longer string. I'd get too many "hits" for one word.
    I really wish I could understand why you get the right boolean returned, but I always get TRUE. Are you sure? Did you try searching for text that doesn't exist? Does it scroll to it, too, as promised?
    Maybe I should downgrade... !
    Jon_Pyne@adobeforums.com Guest

  9. #8

    Default Re: AcroExch.AVDoc.FindText()

    For me it works correct - I only dislike the msgbox "not found", when the value is false.

    Another way would be be to read the text of the page(s) and anlyse it in VBS.

    Attached a code snipet for that.

    HTH, Reinhard

    ------------------------------

    '// Save this as xxx.vbs and start with Double Click
    '// It gives you the text of an already opened PDF
    '// if Acrobat or no Doc is open you get an ErrorMsg
    set WshShell = CreateObject ("Wscript.Shell")
    WshShell.AppActivate("Adobe Acrobat")
    WScript.Sleep 500
    '// get the active Document
    Set AcroApp = CreateObject("AcroExch.App")
    Set AVDoc = AcroApp.GetActiveDoc
    Set PDDoc = AVDoc.GetPDDoc

    Set PdfPage = PDDoc.AcquirePage(1) '<<--SET in FILE! =Pagenumber Set PageHL = CreateObject("AcroExch.HiliteList") PageHLRes = PageHL.Add(0,9000) '<<--SET in FILE! (Start,END[9000=All]) Set PageSel = PdfPage.CreatePageHilite(PageHL)

    for i = 0 to PageSel.Getnumtext - 1
    pdfData =PDFData & PageSel.GetText(i)
    Next

    msgBox PDFDATA
    Reinhard_Franke@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139