Copy link to clipboard
Copied
Hello,
I am creating a simple script to automate exporting a document as a pdf. How can I prompt the user for the export location with a file browser dialog? (Using javascript). Here is the script:
----
// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");
// get document name
var myDocName = app.activeDocument.name;
// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);
// create exported filename
var myFile = File("/c/"+newDocName+" - PRESS.pdf");
// export the PDF
app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);
----
Right now it exports the PDF to /c/ - but I'd like to be able to browse for the export location. Can this be done?
You can select a folder with Folder.selectDialog()
Try with below code:
...// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");
// get document name
var myDocName = app.activeDocument.name;
// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);
//select output folder
var myOutputFolder = Folder.selectDialog( 'Select output folder');
// create exported filename
var myFile = File(myOutputFolder + "/" + newDocName + " - PRESS.pdf");
// export the PDF
a
Copy link to clipboard
Copied
You can select a folder with Folder.selectDialog()
Try with below code:
// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");
// get document name
var myDocName = app.activeDocument.name;
// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);
//select output folder
var myOutputFolder = Folder.selectDialog( 'Select output folder');
// create exported filename
var myFile = File(myOutputFolder + "/" + newDocName + " - PRESS.pdf");
// export the PDF
app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);
Shonky
Copy link to clipboard
Copied
Perfect! Thank you very much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now