jsx export PDF using preset but pageRange is an alternate layout
Hi, all,
Hoping a kind soul can come to the rescue.
I'm trying to get this script working so that every open document will have four PDFs exported, using two PDF presets and two alternate layouts:
"[Press Quality]" - (US Letter and A4)
"Press Quality with Crops" - (US Letter and A4)
In the Adobe PDF Presets export options, it's easy to see the alternate layout names but I can't seem to be able to get the script to use them.


...and I can't seem to get it to stop opening the PDF in Acrobat upon export.
Here's the script so far:
// amended from Kai's script found here https://creativepro.com/topic/export-pdf-in-original-folder/
// your Adobe PDF Presets name
var pdfPreset = app.pdfExportPresets.itemByName("[Press Quality]");
if (!pdfPreset.isValid) {
alert("Your preset doesn’t exist!");
exit();
}
while (app.documents.length) {
var curDoc = app.activeDocument;
// check if the doc was saved or modified
if (!curDoc.saved || curDoc.modified) {
alert ("Save your doc before!");
exit();
}
//PDF alternate layout name e.g. US or A4
pageRange = "US";
viewPDF = false;
// build the PDF name
var pdfName = curDoc.name.replace(/\.indd$/i,"_US.pdf");
// path to the folder of the indd-file
var fPath = curDoc.filePath;
// reference to the new file
var pdfFile = new File(fPath + "/" + pdfName);
// export the current file …
curDoc.exportFile(ExportFormat.pdfType, pdfFile, false, pdfPreset);
// … and close the document
curDoc.close(SaveOptions.NO);
}Many thanks if anyone can point me in the right direction.
