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!
Beto
November 18, 2015 9:18 pmHi.
I need export these PDFs to different folders on my network.
Would you like to help me with the path parameters?
Admin
November 18, 2015 10:34 pmHi Beto,
I can try. What were you hoping to do?
Beto
November 19, 2015 1:58 pmHi. Thanks for reply!
Ok. You are right. I need to be more clear.
Thisscript (below) can create two kinds of pdf in the same folder.
I need some help with parameters for two paths and one pdf in each folder. Eg like this:
INDD FILE to
PDF _High (path/ folder 1 /PRESS)
PDF _low (path/ folder 2 /REWIEW)
Of course, the destination folders are already well in place.
Script below..
d = app.activeDocument;
preset1 = app.pdfExportPresets.itemByName(“[Smallest File Size]”);
preset2 = app.pdfExportPresets.itemByName(“[Press Quality]”);
if (!(preset1.isValid && preset2.isValid)){
alert(“One of the presets does not exist. Please check spelling carefully.”);
exit();
}
mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
mSourcePath = d.fullName.parent.toString();
mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
mTargetPath=mRootPath.concat(‘/final/’);
mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
mNameWeb= mTargetPath.concat(mDocName,’_baixa.pdf’);
if (!d.saved){
d.save;
}
d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);
Mike Brogan
May 30, 2017 6:22 pmwas this question ever answered? I have a similar situation where I need to export a hi res and a low res in to two separate sub folders: Final_Deliverables/Publish for the hi res and Final_Deliverables/Proofs for the low res. the Final_Deliverables folder is a top level folder of the project.
Mike Brogan
May 31, 2017 12:27 amI was able to build out what was necessary to move the files to the sub folders
Thanks for making the Script available!!!
scott
June 6, 2018 10:42 pmwould you bet able to share the two folder version of this script…two folders one PDF in each
scott
Andy Ward
January 26, 2018 5:15 pmHi
Can you alter this script so it can take off “AW” at the end of a file name and change it to “HR” and “LR” accordingly?
That’d be ideal for me!!!
Regards
Andy
Ariel
January 30, 2018 2:07 amWell, I can give you a clue 😉
Given the following
… the following line will change the “AW” to “HR”:
Using this info, it should not be too difficult to modify the script…
Andy Ward
February 23, 2018 5:38 pmHi Ariel
Apologies for my complete beginner/newbie/stupid/ignorant level of knowledge but would you be able to copy and paste a full script into a reply please??
My presets are called “200dpi” and “300dpi” and where the last letters of my Indesign document is “AW” it would need to swap out for “LR” and “HR” accordingly. And this all needs to happen with the triggering of one script.
Sorry if that’s totally inept of me but I have no concept of scripting!
Totally happy to pay for your services on this – or even donate to a charity.
Thanks!!
Andy
Ariel
February 25, 2018 2:21 pmHi Andy,
Try this:
Ariel
Andy Ward
February 26, 2018 12:00 pmHello. I’ve got the same error message again ending with “Offending Text: \”
Any ideas?
Timothy G LeCroy
March 22, 2018 12:06 amWill this script create multiple pdfs from different layers inside an InDesign document?
We currently create multiple layers of a pdf, but the exported file that is generated is one file with the layers that must be toggled on and off. Would like to be able to create separate pdfs from the different layers inside the source InDesign file. If this is possible please explain the necessary steps. If that is not clear please advise.
Thank you.
Tim
Ariel
March 22, 2018 12:31 amHi Tim,
This script won’t do that. It would need some custom work, so get in touch if you would like a quote for a script that will do exactly what you ask.
Thanks,
Ariel
Tim
March 22, 2018 8:00 pmHello Ariel,
Could you go ahead and provide a quote to create the script (multiple pdfs from multiple layers and one InDesign file) and advise?
Thanks,
Tim
Andy Ward
March 22, 2018 2:00 pmHi Ariel
This script does’t quite work. Any chance you could sort it for me?
Totally happy to pay for your work! Give me a quote and let’s do this!
Andy
Rahul
April 20, 2018 11:13 amHi Andy – has the coding problem been fixed? I’m trying to get this working but can’t also. If you’ve fixed it, could you share the script please? Cheers!
Andy Ward
April 20, 2018 1:01 pmHi. I paid Ariel for fix it and get it finalised for me. Works perfectly now.
Andy Ward
March 22, 2018 2:00 pm🙂
Atul Rajput
March 27, 2018 3:51 pmI have a document with more than 50 pages, and I need to create a single pdf with all the pages by script, Please help me out.
Thanks in advance
Ariel
April 13, 2018 11:32 amHi Atul: Have a look at the script above. The last line is the command to actually export the PDF from InDesign. The first few lines set up some options. See if you can work with that and take it from there…
Lindsay
June 8, 2018 12:14 amHi, I am working with an INDD file with several pages and I need to export only one page with the two presets. Is this possible with this script to add that code in? Thanks!
Ariel
June 8, 2018 12:18 amHi Lindsay,
The same page for both PDFs, or a different page for each PDF?
Lindsay
June 8, 2018 12:53 amHi Ariel, the same page for both PDFs.
scott
June 9, 2018 12:04 amwould anybody have the two folder (one pdf into each folder) version of this script?
scott
scott
June 14, 2018 11:58 pmthis works for the two folder 1 pdf in each (high res folder and low res folder)
d = app.activeDocument;
preset1 = app.pdfExportPresets.itemByName(“press spreads and crops”);
preset2 = app.pdfExportPresets.itemByName(“smallest size_spreads”);
if (!(preset1.isValid && preset2.isValid)){
alert(“One of the presets does not exist. Please check spelling carefully.”);
exit();
}
mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
mSourcePath = d.fullName.parent.toString();
mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
mTargetPath=mRootPath.concat(‘/Final_Art/LowRes_PDF_Final/’);
mNameWeb= mTargetPath.concat(mDocName,’_LOW.pdf’);
mTargetPath=mRootPath.concat(‘/Final_Art/Print_PDF/’);
mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
if (!d.saved){
d.save;
}
d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);
Rahul Baxi
June 15, 2018 10:25 amHi Scott thanks for this. Just a quick question. I’m still no good at scripts so wondering if my presets are PDF/X-1a:2001 and Smallest File Size – then how can I adapt the script so it will create this.
Ariel
June 15, 2018 4:51 pmRahul: Just insert your preset names in lines 2 & 3 of the script (that begin preset1 = and preset2 =). Replace the existing name with your preferred preset name.
scott
June 15, 2018 5:08 pmalso you will need to have the same folder structure (or change the reference to match yours) where it references ‘/Final_Art/Print_PDF/’ and ‘/Final_Art/LowRes_PDF_Final/’
my structure is……
server
>project folder
>Final_Art
>Final_Collect_Printer
>LowRes_PDF_Final
>Print_PDF
Rahul Baxi
June 18, 2018 9:43 amHi Scott
I’ve copied your file structure and it’s not working. Could you do me a massive favour and cut and paste the exact script you are using. I’ll then copy it. Hopefully, that should do the trick. Also if you have your PDF options I wouldn’t mind having those also.
Thanks very much in advance. Have a fab and thanks for your help.
Rahul
scott
June 18, 2018 5:33 pmthe above is the script i am using…
my pdf job options are just a bastardization of the press ready one supplied by adobe (i added crops and bleeds, spreads and a few other things)
the file structure got messed up a bit
lets try again
my structure is……
server
>>project folder
>>>Final_Art
>>>>Final_Collect_Printer
>>>>LowRes_PDF_Final
>>>>Print_PDF
Rahul Baxi
June 18, 2018 7:00 pmHi Scott – thanks for this but not working. Error with line 8. Here is my script. and my folders are as follow:
Server
>project folder
>>Final_Art
>>>J0001_Board of Governors End of Year Dinner Invite.indd
>>>Final_Collect_Printer
>>>LowRes_PDF_Final
>>>Print_PDF
d = app.activeDocument;
preset1 = app.pdfExportPresets.itemByName(“PDF/X-1a:2001”);
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();
}
mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
mSourcePath = d.fullName.parent.toString();
mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
mTargetPath=mRootPath.concat(‘/Final_Art/LowRes_PDF_Final/’);
mNameWeb= mTargetPath.concat(mDocName,’_LOW.pdf’);
}
mTargetPath=mRootPath.concat(‘/Final_Art/Print_PDF/’);
mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
}
if (!d.saved){
d.save;
}
d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);
scott
June 18, 2018 8:10 pm….its getting beyond me. I just stood on the shoulders of those who came before me
scott
MIKE
June 18, 2018 8:58 pmHello Rahul!
please confirm you document is saved on the top level of the Final_Art folder, the folder Final_Collect_Printer should be a sub folder of the “Project folder” and the folders LowRes_PDF_Final
and Print_PDF should be sub folders of Final_Collect_Printer.
I made a few changes so you can try this…….
d = app.activeDocument;
preset1 = app.pdfExportPresets.itemByName(“[PDF/X-1a:2001]”);
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();
}
mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
mSourcePath = d.fullName.parent.toString();
mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
mTargetPath=mRootPath.concat(‘/Final_Collect_Printer/LowRes_PDF_Final/’);
mNameWeb= mTargetPath.concat(mDocName,’_LOW.pdf’);
}
mTargetPath=mRootPath.concat(‘/Final_Collect_Printer/Print_PDF/’);
mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
}
if (!d.saved){
d.save;
}
d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);
MIKE
June 18, 2018 9:14 pmone more minor change…………..
d = app.activeDocument;
preset1 = app.pdfExportPresets.itemByName(“[PDF/X-1a:2001]”);
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();
}
mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
mSourcePath = d.fullName.parent.toString();
mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
mTargetPath=mRootPath.concat(‘/Final_Collect_Printer/LowRes_PDF_Final/’);
mNameWeb= mTargetPath.concat(mDocName,’_LOW.pdf’);
}
mTargetPath=mRootPath.concat(‘/Final_Collect_Printer/Print_PDF/’);
mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
}
if (!d.saved){
d.save;
}
d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);
Lindsay
June 18, 2018 11:27 pmIs it possible to export single page pdf with the two presets and two locations instead of the entire INDD file? For example, only exporting page 3 of a 6 page document? Thanks!
Ariel
August 17, 2018 2:28 amHi Lindsay: You can now do this with the commercial version of the script (Extract Pages): http://www.id-extras.com/products/extract-pages
PM
August 16, 2018 7:57 pmHi,
I want to add a Print to PDF in this script using my Print Preset named “T. Rowe Print Ready”. Any idea how? It should be Two Export PDF and One Print to PDF.
Ariel
August 17, 2018 2:24 amHi PM,
I see you got some answers to this on the Adobe forum. Here’s the link if anyone has a similar problem: https://forums.adobe.com/message/10564615
Scott
November 19, 2018 8:54 pmok, I need a bit more help on this…
how do you make an if/then concept
if the folder specified in the script exist then proceed as normal
If not the folder exist throw up a dialog stating the folder does not exist and give the user a save dialog box where they are able to navigate to the folder manually
i am going to give this script to about 6 designers i work with and don’t want them coming to me if it just hard errors on them
scott
Ariel
January 4, 2019 4:31 pmHi Scott,
InDesign’s Folder object has a (wait for it) “exists” property.
So in principal you would just write:
In the original script I posted here, the PDFs are saved alongside the original InDesign document, so there’s no danger of the folder not existing.
In some of the modifications posted in the comments, it could indeed happen that the folder doesn’t exist, so then use the general construct demonstrated above.
And, as always, feel free to get in touch if you would like to have some custom scripting done.
Alan
January 23, 2019 10:35 pmHello! A few questions as I’m trying to modify this code for my own use.
– Is there a way to change the file output file names so there is a prefix at the beginning rather than a suffix and the end? I’ve tried the following:
name2 = “prefix-“+thePath+”.pdf”;
but I get an error message indicating that it’s trying to save to a folder named “prefix” instead of adding the string to the beginning of the file name.
– This may be beyond the scope of this script, but could it be modified to extract each page in a document individually?
Ariel
January 24, 2019 1:07 amHi Alan,
If you just add the prefix to the beginning of the variable thePath, you are adding it to the beginning of the path, which is clearly wrong. You would be wanting to add it to the beginning of the file name only, not the entire path.
To save as separate pages is a little more complicated.
To me it sounds like you could benefit from the full version of Extract Pages, which would let you easily do both these things and a lot more…
Alan
January 24, 2019 6:05 pmNot so clear to a beginner!
Thanks anyway.
Daniel
November 22, 2019 5:14 pmhi
This excellent script have one problem for us.
If I manually export pdf for example page 72, indesign pdf export dialog remember this. After running this script only page 72 is exported.
Can you modify this script to reset pdf dialog to “all” pages?
Ariel
November 25, 2019 7:23 pmAdding this line to the start of the script should do the trick:
app.pdfExportPreferences.pageRange = “”;
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:
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
Roy Solorio
August 7, 2020 3:33 amSuch a simple bit, but that worked like a charm. Thanks Ariel.