Open and close PDF files from a CVS list

I would like to perform actions on a list of files. I have them in a CSV file. I can read in OK in the Console, but cannot open them. The paths are correct, I can open a. But in the loop, it does not work. Why?

var oFile = util.readFileIntoStream("/C/test.txt");
var cFile = util.stringFromStream(oFile, "utf-8");


var n = cFile.split(",");


//second part
for (var i in n) {
  var otherDoc = app.openDoc(n[i]);
  otherDoc.closeDoc();
}

undefinedInvalid location "/ D/test.pdf. File or folder does not exist.

NotAllowedError: Security settings prevent access to this property or method.

Undefined App.openDoc:2:Console: Exec

undefined

OK, this is actually not a line break, but called BOM, which appears as the first character in some UTF-8 text files, especially those created on Mac.

All you have to do is to remove strings. You can use something like this in your loop:

var filePath = n[i].replace("\uFEFF", "");
var otherDoc = app.openDoc(filePath);

You are benefiting from my experience here because I recently encountered this same problem and it took me several hours of frustration to solve...

Tags: Acrobat

Similar Questions

Maybe you are looking for