Copy link to clipboard
Copied
Working on my first folder level javascricpt at the moment and running into an issue with NotAllowedError: Security settings prevent access to this property or method. Any tips on escalating do i need to run in the apps folder rather than user?
// Define the file path and name of the .csv file
var filePath = "/G/acro/sheet.csv";
// Define the delimiter used in the .csv file
var delimiter = ",";
// Open the .csv file
var file = app.openDoc(filePath);
// Get the contents of the .csv file
var contents = file.extractText();
// Split the contents into an array of rows
var rows = contents.split('\n');
// Loop through each row and create a corresponding text field
for (var i = 0; i < rows.length; i++) {
// Split the row into an array of values
var values = rows[i].split(delimiter);
// Create a new text field with a unique name
var fieldName = "text" + i;
this.addField(fieldName, "text", i, [50, 700, 200, 730]);
// Set the value of the text field to the corresponding value from the .csv file
this.getField(fieldName).value = values[0];
}Thank you very much for taking the time to look at this!
Copy link to clipboard
Copied
The openDoc method can only be used on PDF files, and there's no "extractText" method in Acrobat.
Copy link to clipboard
Copied
If you want to read the contents of a text file use util.readFileIntoStream().
Copy link to clipboard
Copied
Ive switched it to readFileIntoStream but I am now recieving this error
(NotAllowedError: Security settings prevent access to this property or method.
Util.readFileIntoStream:8:Folder-Level)
I am currently running the script in the user folder do i need to switch to the app folder thanks!
Copy link to clipboard
Copied
You have to run it from a privileged context.
See: https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts
https://acrobatusers.com/tutorials/using_trusted_functions
Copy link to clipboard
Copied
I suggest you run it from the Console first (which is in a privileged context) to see that it works.
Then deal with the trust issues.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more