Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Export Multiple Page Ranges to seperate PDFs from 1 export

Community Beginner ,
Dec 08, 2019 Dec 08, 2019

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!

 

 

 

TOPICS
How to , Import and export , Scripting
8.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Dec 09, 2019 Dec 09, 2019

(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

...
Translate
Community Expert , Oct 19, 2024 Oct 19, 2024

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
...
Translate
Explorer ,
Oct 19, 2024 Oct 19, 2024

It's a good solution for better use of the script. Thanks a lot for the suggestion!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

Another good idea, though it might make the list in the scriopts forlder a bit long if there are a lot of presets.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 19, 2024 Oct 19, 2024


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

https://community.adobe.com/t5/indesign-discussions/script-export-page-ranges-to-multiple-pdfs-fast-... 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

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();
	}
}

 

 

Screen Shot 20.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 19, 2024 Oct 19, 2024

@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

 

Captura de Pantalla 2024-10-19 a la(s) 17.49.37.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2024 Oct 19, 2024

@LMatiel

 

Can you post screenshot before you click OK - so we can see Page Range you've entered.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 19, 2024 Oct 19, 2024

These are the screenshots of the process

Captura de Pantalla 2024-10-19 a la(s) 18.27.10.jpgCaptura de Pantalla 2024-10-19 a la(s) 18.28.06.jpgCaptura de Pantalla 2024-10-19 a la(s) 18.28.16.jpg







 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2024 Nov 01, 2024

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

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();
	}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 20, 2024 Oct 20, 2024

@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!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2024 Nov 01, 2024

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2019 Dec 09, 2019

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 02, 2025 Mar 02, 2025

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
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 29, 2025 Apr 29, 2025
LATEST

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://community.adobe.com/t5/indesign-discussions/script-export-page-ranges-to-multiple-pdfs-fast-...

 

https://github.com/MoebiusSt/exportPageRangesToPDF.jsx

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines