8 Replies Latest reply on Aug 12, 2010 7:17 AM by gkaiseril

    Getting the form field values and names

    Balaust

      Hi anybody please help me out this,

       

      I have tried the following code , but it returns me the result as  ("No fields found")

       

      I am not able to attach my pdf here, i have tried with one more method also , still it doesn't return anything.

       

      When i gone through the Forum , i heard something about LiveCycle Form. if my pdf is Livecycle form based then please give me the code to reterive the form fields names and values,

       

      method1:

       

      '// Let's start

      set WshShell = CreateObject ("Wscript.Shell")
      WshShell.run "Acrobat.exe c:\F4.pdf"
      While not WshShell.AppActivate("Adobe Acrobat") : Wscript.Sleep 1000 : Wend


      '// Set/Get Acrobat Objects
      Set App = CreateObject("AcroExch.App")
      Set AVDoc = App.GetActiveDoc
      Set PDDoc = AVDoc.GetPDDoc
      Set JSO = PDDoc.GetJSObject

       

      '// search for fields and get Name+value
      txt = ""
      if jso.numFields then
      for i = 0 to jso.numFields -1
          fn = jso.getNthFieldName(i)
          'msgbox(x)
          set f = jso.getField(fn)
          fv = f.value
          txt = txt  &fn &"=" &fv &";"
        next
      msgbox(txt)
      else
      msgbox("No fields found")
      end if

       

      Set AVDOC = Nothing
      Set PDDoc = Nothing
      Set JSO = Nothing

       

       

      Method2:

       

      MY_FILE = "C:\output.pdf"
      Set AcroExchApp = CreateObject("AcroExch.App")
      Set AcExAVDoc = CreateObject("AcroExch.AVDoc")
      bOK = AcExAVDoc.Open(MY_FILE, "")
      AcExAVDoc.BringToFront

      sMsg = ""

      If (bOK) Then
      Set AFormAut = CreateObject("AFormAut.App")
         
           
              If AFormAut.Fields.Count = 0 Then
                  sMsg = "There are no field(s) to read from this PDF"
              Else
                  sMsg = "There are " & AFormAut.Fields.Count & " fields in this PDF document"
              End If
        

          
              For Each FormField In AFormAut.Fields
                  Fieldname = FormField.Name
                  Fieldvalue = FormField.Value
                 ' MsgBox AFormAut.Fields(Fieldname).Value
                  sMsg = sMsg & vbLf & ", " & Fieldname & ", " & AFormAut.Fields(Fieldname).Value & ", " & FormField.IsTerminal
                  MsgBox sMsg