1 Reply Latest reply on Nov 20, 2008 6:27 AM by (korcan)

    C# OLE Acro Javascript Form Filling

      Starting from SDK samples I have developed a small app.

      I don't need to show the document in reader of writer. so I didn't want to use Av.. class

      So the problem: I cannot set the vale of the fields in fact I could'nt understand what is comming from getField It is System.__ComObject

      I need to set the value of the field and the last call (I have also tried SetProperty) always fails.

      Any help will be appriciated.

      Regards.

      CAcroApp acroApp = new AcroAppClass();
      ...
      CAcroPDDoc pdDoc = new AcroPDDocClass();

      // Open the pdf
      bool lockresult=acrobatApplication.Lock("myApp");
      //if (!avDoc.Open(docName, "contract Fields"))
      if (!pdDoc.Open(docName))
      {
      result=-1;
      }
      ...
      object jsObj=pdDoc.GetJSObject();

      Type T = jsObj.GetType();
      Object[] parms = new Object[1];
      parms[0] = "txtName";
      //parms[1] = "Korcanowski";
      Object oField = null;

      oField = T.InvokeMember(
      "getField",
      BindingFlags.InvokeMethod |
      BindingFlags.Public |
      BindingFlags.Instance,
      null, jsObj, parms);

      if (oField !=null)
      {
      Type oFieldType = oField.GetType();
      oFieldType.InvokeMember(
      "value",
      BindingFlags.InvokeMethod |
      BindingFlags.Public |
      BindingFlags.Instance,
      null, jsObj, parms);
      //FieldInfo[] oFieldFields = oFieldType.GetFields();
      }
        • 1. Re: C# OLE Acro Javascript Form Filling
          Level 1
          uhh,
          trial and denial solved the problem but performance suffers while getting javascript object and propery update... Maybe letting form rendered on the screen ans using forms lib is cheaper in CPU cycles...

          if (oField !=null)
          {
          Object ox = null;

          Type oFieldType = oField.GetType();
          ox =oFieldType.InvokeMember(
          "value",
          BindingFlags.SetProperty |
          BindingFlags.Public |
          BindingFlags.Default|
          BindingFlags.Instance,
          null, oField, new object[] { "King Fisher" });
          //Type oXType = ox.GetType();
          //FieldInfo[] oFieldFields = oFieldType.GetFields();
          }