20 Replies Latest reply on Jun 20, 2017 11:23 AM by Karl Heinz Kremer

    Having issues with batch import javascript from txt file with Enterprise security Trust and Privilege issues?

    Monteigo99 Level 1

      Hello all,

      I'm lost and have been struggling with this for a couple weeks now. I am a decent beginner level who can understand js, copy it and past, then modify to get it working. I am much more limited with regards to creating new scripts from scratch.

       

      I have a js 'Action' that performs a batch import: locates txt file, imports data for first record, saves the file with one of the field names, then automatically, pulls the next record and repeats.

       

      I'm using Acrobat Pro XI.

       

      The problem is that while it populates the data, it will not save the new file to my folder, and thus, will not proceed to the next file.

       

      I have performed the research and have traced the problem to the security issues associated with saving files on my company's drives. I believe this is a Trust function and Privilege scripting. I don't quite seem to understand

      1) how to create a .js file that I save in the javacript folder,

      2) the javascript folder location is different from where I have seen in blogs that it is supposed to be (it is here: C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Javascripts), and

      3) the difference between writing the trust script into the Action js and simply creating a js to go and retrieve the trusted script from the js file.

       

      I have tried all sorts of variations to no avail. Any assistance would be really appreciated.

       

      Current script:

      /* Autofill OPPE Records */
      // specify the filename of the data file
      var fileName = "/c/Users/XXXXX/Desktop/Temp Files/NeuroTestDatafile.txt";
      var outputDir = "/c/Users/XXXXX/Desktop/Temp Files/OPPEAutoPopTest/";

      var err = 0;
      var idx = 0;
      while (err == 0){
      err = this.importTextData(fileName, idx); // imports the next record
      if (err == -1)
      app.alert("Error: Cannot Open File");

      else if (err == -2)
      app.alert("Error: Cannot Load Data");

      else if (err == 1)
      app.alert("Warning: Missing Data");

      else if (err == 2)
      app.alert("Warning: User Cancelled Row Select");

      else if (err == 3)
      app.alert("Warning: Missing Data");   

      else if (err == 0){
           this.saveAs(outputDir + this.getField("Provider").value + ".pdf")

      }
      }