Copy link to clipboard
Copied
Dear Community,
I have been using Indesign since CS2 and I have never came across this particular problem before. I am hoping someone here can help me. I have 7 seperate indesign documents each from a data merge. Each document has close to 300 pages. What I need is very simple but for the life of me I cannot figure out how to do it efficiently. I need to export multiple page ranges for each indesign document and have each range be a seperate pdf. Here's an example of what I mean.
Indesign Document:
1-2, 4-5, 7-16, 18-19, 21-30, 32-35, 37-38, 40-49, 51-52, 54-57, 59-74, 76-79, 81-82, 84-85, 87-92
I need a way to export so that basically the comma means *NEW PDF*.
The only way I found so far to do this is to manually export the ranges 1 at a time which takes literally hours to go through each id file OR I found 1 plugin this morning that may do it called "extract Pages".
https://www.id-extras.com/products/extract-pages/
There's got to be an easier way right? I shouldn't have to spend $50 to do this seemingly insanely simple export.
Any ideas guys?
Thanks!
(Sorry, didn't mean to leave you hanging. I must be in a different time zone -- my original answer was done right before closing down for the night.)
I've found your bug -- and it's actually toted as a "feature". My Mac had no problems with the script but I get your error on my Windows 'chine as well. Apparently the default location to save in, if no path has been given, is the scripts folder. I didn't notice because my Mac automatically opened the files as they were created and I just glanced a
...The exportFile method needs a file path, which was not included in the code I pasted from jongware’s first post. Maybe this:
makeDialog();
var pp, pglist;
function makeDialog(){
var theDialog = app.dialogs.add({name:"Choose a Preset", canCancel:true});
with(theDialog.dialogColumns.add()){
staticTexts.add({staticLabel:"Export Preset:"});
staticTexts.add({staticLabel:"Page Range:"});
}
with(theDialog.dialogColumns.add()){
pp = dropdowns.add({str
Copy link to clipboard
Copied
It's a good solution for better use of the script. Thanks a lot for the suggestion!
Copy link to clipboard
Copied
Another good idea, though it might make the list in the scriopts forlder a bit long if there are a lot of presets.
Copy link to clipboard
Copied
Old topic, but it anyone is still working on this, I would suggest the a good way to handle @LMatiel 's request would be to implement a dropdown box to select a preset rather than trying to choose each setting, but perhaps that was what they meant.
Copy link to clipboard
Copied
Thanks for the reply, there is another script that contains the dropdown menu with all the pdf settings that are saved in indesign but I can't get it to work in osx
Here
Copy link to clipboard
Copied
Sorry, I'm not a scripter so can't help with that. See you posted in the other thread, so perhaps the author will get back to you there.
Copy link to clipboard
Copied
Hi @LMatiel , Try this:
makeDialog();
var pp, pglist;
function makeDialog(){
var theDialog = app.dialogs.add({name:"Choose a Preset", canCancel:true});
with(theDialog.dialogColumns.add()){
staticTexts.add({staticLabel:"Export Preset:"});
staticTexts.add({staticLabel:"Page Range:"});
}
with(theDialog.dialogColumns.add()){
pp = dropdowns.add({stringList:app.pdfExportPresets.everyItem().name, selectedIndex:3, minWidth:80});
pglist = textEditboxes.add({editContents:"", minWidth:350});
}
if(theDialog.show() == true){
pp = app.pdfExportPresets.item(pp.selectedIndex);
pglist = pglist.editContents.split(',');
for (i=0; i<pglist.length; i++){
app.pdfExportPreferences.pageRange = pglist[i];
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File('pages_'+pglist[i]+'.pdf'), false, pp);
}
theDialog.destroy();
}
}
Copy link to clipboard
Copied
@rob day Thanks for the reply, I installed the script and ran it, it shows me all the settings to choose from that I need but when I want to generate the PDF it shows me this alert
Copy link to clipboard
Copied
Copy link to clipboard
Copied
These are the screenshots of the process
Copy link to clipboard
Copied
Hi, I'm learning scripting so very much a newbee. When run this script, the final pdf's that are exported are named the page range value. Is there a way to have the page range be a suffix added to the filename?
Thanks for any help or direction you might be able to give.
Copy link to clipboard
Copied
The exportFile method needs a file path, which was not included in the code I pasted from jongware’s first post. Maybe this:
makeDialog();
var pp, pglist;
function makeDialog(){
var theDialog = app.dialogs.add({name:"Choose a Preset", canCancel:true});
with(theDialog.dialogColumns.add()){
staticTexts.add({staticLabel:"Export Preset:"});
staticTexts.add({staticLabel:"Page Range:"});
}
with(theDialog.dialogColumns.add()){
pp = dropdowns.add({stringList:app.pdfExportPresets.everyItem().name, selectedIndex:3, minWidth:80});
pglist = textEditboxes.add({editContents:"", minWidth:350});
}
if(theDialog.show() == true){
pp = app.pdfExportPresets.item(pp.selectedIndex);
pglist = pglist.editContents.split(',');
var path = app.activeDocument.fullName.path;
for (i=0; i<pglist.length; i++){
app.pdfExportPreferences.pageRange = pglist[i];
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File(path+'/pages_'+pglist[i]+'.pdf'), false, pp);
}
theDialog.destroy();
}
}
Copy link to clipboard
Copied
@rob day Thank you very much and I apologize that I couldn't test it before, it works perfectly, the script allows you to select the page range to generate the pdfs and the corresponding settings. It saves the file in the same place where the .indd is, it doesn't allow you to choose another location.
It works correctly, thank you very much!!!
Copy link to clipboard
Copied
Change the following line to this:
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File('pages_'+ app.activeDocument.name.replace(/\.indd/gi,"") + "_" + pglist[i]+'.pdf'), false, pp);
Copy link to clipboard
Copied
Jongware said:
…I checked on my Windows machine and indeed it tries to store the files in the Scripts folder, which is inside a "protected folder" (a Microsoft "feature", so not a bug ...). …
Was this the Application folder of your Scripts panel?
Then I'd try to store the script in the User folder of the Scripts panel.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
It's a bit late but here is an updated version that opens the pdf export window so you can adjust the settings for your export.
//DESCRIPTION:Export page ranges with single PDF Export Dialog
// Modified on 02-Mar-2025
pglist = prompt('Page list', '');
path = app.activeDocument.fullName.path;
pglist = pglist.split(/,\s*/);
// Ask the user to manually configure the export settings once
var pdfFile = new File(path + '/temp_export.pdf');
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, pdfFile, true); // Opens dialog once
pdfFile.remove(); // Delete temporary file
// Apply the same settings to the rest
for (i = 0; i < pglist.length; i++) {
app.pdfExportPreferences.pageRange = pglist[i];
var finalPdfFile = new File(path + '/pages_' + pglist[i] + '.pdf');
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, finalPdfFile, false); // Uses the same settings
}
Copy link to clipboard
Copied
Thank you for taking the time to revisit this Wael. I agree that a version that opens the export dialogue would be useful. However, I am afraid your script did not work for me with ID CS6 on a 700+ page doc which needed a PDF for each 20 pages. ID crashed and closed without giving an error. I tried this twice. First time: I tried to extract from page 40 onwards in batches of 20. Second time: I started my page list from 1 with no gaps in the sequence.
The script by @rob day worked for me very well. I pasted a list in the pop-up box "1-20, 21-40, 41-60..." and PDFs were exported to the working folder of the document. After each PDF is exported it is opened which means a lot of PDFs were opened!
Lastly, there is another thread in the community on this topic which has a Github sin-off:
https://github.com/MoebiusSt/exportPageRangesToPDF.jsx
Find more inspiration, events, and resources on the new Adobe Community
Explore Now