Script to auto-place PDFs failing on password-protected PDFs
I am iterating through a file array and placing PDFs on new pages, and some of the files are password protected. If the user doesn't know the password, I'd like them to be able to cancel and skip to the next file. Does anyone know how to access this part of the file through ExtendScript or a try/catch to solve for it? I have a try/catch on the frame.place() function, but that didn't work. Thanks. Below is the snippet if helpful. I am not doing anything with the file on the page beforehand except getting the list through file.openDialog and sorting the file array by name.
for (var i = 0; i < sortedFiles.length; i++) {
var page = doc.pages.add();
page.appliedMaster = doc.masterSpreads.item(‘A-Master’);
var targetFrame = page.rectangles.add({
geometricBounds: [.9, .5, 10.5, 8],
strokeWeight: 1,
});
try {
targetFrame.place(sortedFiles[i]);
targetFrame.fit(FitOptions.PROPORTIONALLY);
targetFrame.fit(FitOptions.CENTER_CONTENT);
} catch (e) {
$.writeln(e);
continue;
}
}

