July 2018 UPDATE: If you’re looking to export multiple PDFs, using multiple PDF export presets, into multiple folders, using super-flexible filenaming options (including filenames based on the contents of the page itself), our newly updated Extract Pages script is for you! Click here for all the details.
Back in May (2015), someone asked on the Adobe forum if there was a way to export 2 pdfs from InDesign at once, using different presets.
The answer was the following little script, which can be easily adapted to exported more than just 2 PDFs, using any existing PDF presets you like:
// BS"D
// All rights reserved (c) 2015 by Id-Extras.com
// Free to use and modify but do not delete this copyright attribution.
// This script will export 2 pdfs of the current document
// Choose the PDF presets by altering their names below
// The second PDF gets a suffix added to its name.
// Modify the line below beginning name2 = to change the suffix.
// For more InDesign scripts: www.Id-Extras.com
d = app.activeDocument;
// Here you can choose the PDF preset
preset1 = app.pdfExportPresets.itemByName("[High Quality Print]");
preset2 = app.pdfExportPresets.itemByName("[Smallest File Size]");
if (!(preset1.isValid && preset2.isValid)){
alert("One of the presets does not exist. Please check spelling carefully.");
exit();
}
if (d.saved){
thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";
thePath = String(new File(thePath).saveDlg());
}
else{
thePath = String((new File).saveDlg());
}
thePath = thePath.replace(/\.pdf$/, "");
name1 = thePath+".pdf";
// Here you can set the suffix at the end of the name
name2 = thePath+"_xx.pdf";
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);
Enjoy!
Roy Solorio
August 1, 2020 8:54 amLove love love it. Was able to modify and get three count them three different flavored PDFs. Thanks.
Is there a snippet of code that exits the save dialog when the cancel button is selected?
Ariel
August 7, 2020 12:26 amHi Roy,
Glad you’re finding it useful. It’s very satisfying when you can put together yourself a script that works.
The basic idea with the save dialog is that if the user hits the Esc key to exit, or clicks on Cancel, the dialog returns null.
So you would want to test that thePath variable is not null:
if (thePath !== null){ do stuff....}Hope that helps!
Ariel
Andy
August 12, 2020 12:51 pmHi Ariel
A while ago I paid you to sort this script for me (see the comments above) but with updates and re-installs of indesign the script stopped working.
Do you think you could provide me with a fresh script? My Presets are “LR” and “HR” and the existing indesign document would end with “AW.indd”. Each preset would save out with LR or HR instead of the AW letters accordingly if you remember.
Let me know if you’re interested. Completely happy to pay for your service again.
🙂
I’m on v15.1.1 on a Mac if that helps.
Ariel
August 12, 2020 4:03 pmHi Andy,
I just had a quick look, there is nothing in the script that would make it stop working with recent versions of InDesign.
My guess is that it’s a permissions issue on the Mac that is preventing the script from saving to the requested folder.
Ariel