Jump to content

Read PDFs


gcue
 Share

Recommended Posts

I was able to reference a form field and use this script to write to the specific form field in a PDF - thanks ReFran!

I would like to just be able to read a specific form field in a pdf.  seems like it would be easier but cant get the syntax right.  I have acrobat pro.

$App = ObjCreate("AcroExch.App")     ;; start Adobe Acrobat
$App.Show                           ;; show Acrobat or comment out for hidden mode
;; actions
$AVDoc = ObjCreate("AcroExch.AVDoc")     ;; connect to Ac Viewer
If $AVDoc.Open($FilePath,"") Then        ;; open the file
    $PDDoc = $AVDoc.GetPDDoc             ;; get PdDoc from AvDoc
    $AForm = ObjCreate("AFormAut.App")   ;;connect to AForm API

$EX = "" _
        & ' var f = this.getField("'& $fieldname &'")' & @LF _
;~      & ' f.value = "hello"'


        & '"' & $test = '" f.value'     ;this is where i need help!
        
        
    ;msgbox(0,"",$ex)
    $AForm.Fields.ExecuteThisJavaScript($EX)    ;;execute the Js-Code
;~     $PDDoc.save(1,$fileOut)
;~     $app.closeAlldocs()
    $app.exit()
Else
        msgbox(0,"","Coudn't open report")

endif
;; release objects
$AForm = 0
$AvDoc = 0
$PdDoc = 0
$App = 0

 

Link to comment
Share on other sites

$App = ObjCreate("AcroExch.App")     ;; start Adobe Acrobat
$App.Show                           ;; show Acrobat or comment out for hidden mode
;; actions
$AVDoc = ObjCreate("AcroExch.AVDoc")     ;; connect to Ac Viewer
If $AVDoc.Open($FilePath,"") Then        ;; open the file
    $PDDoc = $AVDoc.GetPDDoc             ;; get PdDoc from AvDoc
    $JSO = $PDDoc.GetJSObject   ;; get JS Object from PDDoc
    $test = $oJSO.GetField($fieldname).Value ;; get field value
    msgbox(0,"",$test)

;~     $PDDoc.save(1,$fileOut)
;~     $app.closeAlldocs()
    $app.exit()
Else
        msgbox(0,"","Coudn't open report")

endif
;; release objects
$JSO = 0
$PdDoc = 0
$AvDoc = 0
$App = 0

 

Edited by GMK
Forgot to release objects
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...