var w = new Window("dialog", "Choose a Preset"); var dropdownlist = w.add("dropdownlist", undefined, app.PDFPresetsList); dropdownlist.preferredSize.width = 200; dropdownlist.selection = 0; var choice = dropdownlist.selection; dropdownlist.onChange = function () { choice = dropdownlist.selection; }; var button = w.add("button", undefined, "OK"); button.onClick = function () { saveDocsAsPDF(choice); w.close(); }; w.show(); function saveDocsAsPDF(choice) { // original SaveDocsAsPDF script try { if (app.documents.length > 0 ) { var destFolder = null; destFolder = Folder.selectDialog('Select folder for PDF files.', '~'); if (destFolder != null) { var options, i, sourceDoc, targetFile; options = getOptions(); for ( i = 0; i < app.documents.length; i++ ) { sourceDoc = app.documents[i]; targetFile = getTargetFile(sourceDoc.name, '.pdf', destFolder); sourceDoc.saveAs( targetFile, options ); } alert('Documents saved as PDF'); } } else { throw new Error('There are no document open!'); } } catch(e) { alert( e.message, "Script Alert", true); } function getOptions() { var options = new PDFSaveOptions(); options.pDFPreset = choice; return options; } function getTargetFile(docName, ext, destFolder) { var newName = ""; if (docName.indexOf('.') < 0) { newName = docName + ext; } else { var dot = docName.lastIndexOf('.'); newName += docName.substring(0, dot); newName += ext; } var myFile = new File( destFolder + '/' + newName ); if (myFile.open("w")) { myFile.close(); } else { throw new Error('Access is denied'); } return myFile; } }