4 Replies Latest reply on Dec 19, 2017 1:29 PM by kaylaj30205466

    Batch process for filling form and inserting pages based off of name

    kaylaj30205466

      Hello,

       

      I currently have a title page with form fields that I would like to automate the filling of via javascript. I have set this process up using a tab dlm file (txtfileloc) with the columns titled the same as my form fields and the rows in the same order as the names array.  Additionally, I want to insert pages into the document based off of the array using the insert pages function. Both of these functions appear to be working fine with one exception. The problem is that for each iteration of the loop, instead of starting fresh with my title page again, the loop is just updating the previous file with the new results (so file "b_final.pdf" has the form fields from b, but includes the insert pages results pages from both a and b. C includes the results from a,b and c etc.). I have tried using the closeDoc function at the end of the loop to fix this, but this causes an error and after research I found this is because code is not processed after closeDoc . Does anyone have any advice on how to get the loop to start fresh with the title page each time?

       

      For reference, I have included my current code below:

       

       

      var txtfileloc = "/C/Users/Desktop/Test Files/input.txt";

      var infileloc = "/C/Users/Desktop/Test Files/import/";

      var outfileloc = "/C/Users/Desktop/Test Files/output/";

      var title = "/C/Users/Desktop/Test Files/Title Page Draft.pdf";

      var count=0;

       

      names = ['a','b', 'c', 'd', 'e'];

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

      this.importTextData(txtfileloc,count)

      this.insertPages({cPath:infileloc+names[i]+".pdf"});

      this.saveAs(outfileloc+names[i]+"_final.pdf");

      var count=count+1;

      app.openDoc(title);

      };

       

       

       

      Many thanks in advance, I have spent several days trying to resolve this with no luck.

       

      - Kayla