4 Replies Latest reply on Oct 6, 2016 7:16 AM by colt-ger

    Compare PDF fields with imported xml in a loop

    colt-ger

      Hello,

       

      At the beginning I am a newbie in Acrobat and Javascript.

       

      I have create a PDF-form with Acrobat Pro, my next idea is to fill the PDF with related data via an XML-Import.

      Actual I can import the xml and fill the PDF-Fields hardcoded, this works already via Javascript.

       

      My problem actual is, I want to fill the PDF with the XML-data via an for-loop, because we want to use this script in several PDF-forms and not each form has the same amount of fields.

       

      Here my working script:

       

      var xmldoc = util.readFileIntoStream();

      var xmlstring = util.stringFromStream();

      var myXML = XMLData.parse(xmlstring,false);

      var oNode = XMLData.applyXPath(myXML,"//Customer");

       

      this.getField("CustomerName").value=oNode.Customer.CustomerName.value;

      this.getField("CustomerStreet").value=oNode.Customer.CustomerStreet.value;

      this.getField("CustomerPlace").value=oNode.Customer.CustomerPlace.value;

      this.getField("CustomerSiteName").value=oNode.Customer.CustomerSiteName.value;

      this.getField("CustomerSiteStreet").value=oNode.Customer.CustomerSiteStreet.value;

      this.getField("CustomerSitePlace").value=oNode.Customer.CustomerSitePlace.value;

       

      Here my problem

       

      for(var i=0;i<oNode.length;i++){

      if(this.getField(????)==oNode.Order.???){

      this.getField(???[i]).value=oNode.Order.???[i].value; 

      }

      }

       

      I hope anyone understand what I mean and can help me.

       

      thx in advance

       

      Regards

      Dirk