11 Replies Latest reply on May 24, 2016 9:30 PM by George_Johnson

    process aborted when reading data from a text file (util.readFileIntoStream, stringFromStream)

    ashdflkjh Level 1

      When I run this script in console (Acrobat DC) it always stops after 50 iterations with this error:


      NotAllowedError: Security settings prevent access to this property or method.
      App.openDoc:13:Console undefined:Exec


      My guess is that it cannot find the next path in the test.txt file that has a list of paths. Why? Are there size limitations to this? If I delete the processed paths from the file, it continues fine, for the next 50 paths, and then stops again.


      var oFile = util.readFileIntoStream("/C/test/test.txt");
      var cFile = util.stringFromStream(oFile, "utf-8");
      var n = cFile.split("\n");
      //iterate through array of file paths and operate
      for (var i in n) {
          var dc = app.openDoc(n[i].replace(/(\r\n|\n|\r)/gm,"").replace("\uFEFF", "").replace("\t", ""));
          // Change the author names from "Smith, Jon" to "Jon Smith"
          var names = dc.info.Authors;
          for (var i in names) {
              names[i] = names[i].replace(/,/g, "");
              var nameParts = names[i].split(" ");
              if (nameParts.length>1) {
                  var tmp = nameParts[1];
                  nameParts[1] = nameParts[0];
                  nameParts[0] = tmp;
                  names[i] = nameParts.join(" ");
          var namesAsString = names.join(", ");
          dc.info.Authors = [];
          dc.info.Author = namesAsString;