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

Export Multiple Page Ranges to seperate PDFs from 1 export

Community Beginner ,
Dec 08, 2019 Dec 08, 2019

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!

 

 

 

TOPICS
How to , Import and export , Scripting

Views

6.0K

Translate

Translate

Report

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

...

Votes

Translate

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
...

Votes

Translate

Translate
Community Expert ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

It's quite contradictory to first say it will cost you hours of your time and then say you "should not have to spend $50" on a plug-in that will save you that much time ...

But – fortunately your task is easy to script! This is all it takes -- copy your page range list and paste it into the prompt that appears, and you'll get your PDFs, named as "pages_1-2.pdf" etc.

//DESCRIPTION:Export page ranges
// A Jongware Script 08-Dec-2019
pglist = prompt ('page list', '');
exportPreset = '[High Quality Print]';
pglist = pglist.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, app.pdfExportPresets.item(exportPreset));
}

 

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Agreed. I despise that attitude. $50 to save hours of work?

Seems like a bargain to me.

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Thank you! I'm going to try this right now. I really appreciate your help. I've been scratching my head trying to figure this out. 

 

To your comment on not having to spend an additional $50 – 

I see what you're saying but I have to disagree. I already pay adobe a pretty big monthly stipend. Now, I could see if it were something complex. Yes – if I want to do something insane that isn't really something the software was meant to do fine I can see paying extra money. But to do something so simple that should be a checkmark in the export dialog box i dont think so. This would probably take adobe 15 minutes to implement judging on how quickly you responded. 

 

Thanks again man! I GREATLY APPRECIATE IT 😄

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

But, it's a pretty niche use case. 99% of the installed user base would have no need for such functionality, so while it may be easy to implement, there is no need to when scripting and plugins exist. And, if such a plugin or script is valuable to you, then you should be willing to pay the developer for their time developing something that fulfilled your particular use case. 

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

I'm going to have to respectfully disagree. I see where you guys are coming from... especially if you're a developer making money from features adobe doesn't include. I get it and of course in certain instances I'd 100% agree with you. Where I dileniate is categorizing a task of exporting multiple pdf ranges to multiple pdfs as 'niche' request. I think your 99% number is probably more like 75%. I managed a prepress department for over 10 years and I can tell you without a doubt most full service print shops would love this little check box not to mention mail houses. I'm going to guess that more than takes up 1% of adobe's indesign business by a significant margin.

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

And those certain instances would be what? Features you don't want or need? And what scientific poll did you use to come up with your numbers?

Look, I get it...nobody wants to spend money but sometimes you just have to and AFAIC, there's no better way than to support a developer that makes my job easier.

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

I don't think we're quoting any scientific polls here bob haha. I think we're all talking from personal experience here. Unless Brian is looking at a case study? Not trying to insult anyone here... If I was getting paid 1500 bucks for a job i needed this for I wouldn't mind spending the dough but this just isn't the case in this instance. I wish it were trust me.

 

Off the top of my head?

Oh I don't know let's say I wanted a way to search the indesign document for a certain text variable. It then finds what Im looking for in the document and then exports only the pages that has that variable as pdfs then sorts them in the order I need. That seems like something insane you should have to pay for.

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Nothing is stopping you from submitting a feature request or spending the time to learn the DOM to do this yourself. As you can see from the bug in Jongware's solution, these things aren't trivial even though they may appear to be, especially in an enterprise environment. 

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

That's why I'm here Brian.

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

For the bug, I don't think this is an error in Jongware's code. I would try doing a range export manually using the High Quality Print preset. Chances are it will fail in Background Tasks too. The trick then will be finding an export preference that works for your use case, then change the line in Jongware's code to that preset. I have run into similar issues with exporting lately; there's very little rhyme or reason to it. 

 

And my point was, your "search a doc for text and export those pages in a particular sort order" is very feasible, but not trivial. Nothing in ExtendScript is. And expecting Adobe to add every niche feature request is unreasonable.

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Ahh... got ya. Ya I've been playing with it all day. If it's not the code the only thing I can think is maybe some of the syntax changed in 2020. In ESTK I get "Cannot execute script in target engine 'main'! (#1116) Can't start debug session." and at the bottom the same error string once I add some page numbers... "Failed to export pdf file". I've tried the profile it works in indesign and i've also tried using different ones. Always the same thing. Something with line 9.

 

I really do appreciate the help man. Thank you.

Votes

Translate

Translate

Report

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 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

On second thought, try throwing the word "new" in front of File in line 9: ..., new File('pages...

 

You might need to give the file a path too. Doubt it is a problem with ID 2020... Not much changed in the DOM, if anything. 

Votes

Translate

Translate

Report

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 ,
Dec 09, 2019 Dec 09, 2019

Copy link to clipboard

Copied

Sorry, I had to catch some z's last night haha. it looks like you were on the right track though. I just wanted to say thanks again. I appreciate your help man.

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

[deleted]

Votes

Translate

Translate

Report

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 ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Sorry it took so long to get back.

Ok, so I saved this code into a plain text document and changed the extension to .jsx

When I input a page range whether that be (1-4, 6-8) or (1-4 )or even (1) I am getting the following error.

Im running 2020. Not sure if that makes a difference or not. 

 

Screen Shot 2019-12-08 at 11.54.59 AM.png

Votes

Translate

Translate

Report

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
Advocate ,
Dec 08, 2019 Dec 08, 2019

Copy link to clipboard

Copied

Try this code:

 

pglist = prompt ('page list', '');
if(pglist!=null){
    exportPreset = '[High Quality Print]';
    pglist = pglist.split(',');
    for (i=0; i<pglist.length; i++){
        if(pglist[i].toString().replace(/[0-9(),\s]+/g,'') == ""){
            app.pdfExportPreferences.pageRange = pglist[i];
            app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File('pages_'+pglist[i]+'.pdf'), false, app.pdfExportPresets.item(exportPreset));
            }
        }
    }

 

Best

Sunil

Votes

Translate

Translate

Report

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 ,
Dec 09, 2019 Dec 09, 2019

Copy link to clipboard

Copied

Thank you Sunil. I tried this code and I don't get an error but it doesn't seem to be outputting a pdf. Jongware seems to have cracked it but I GREATLY appreciate your help as well. Thanks man.

Votes

Translate

Translate

Report

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 ,
May 22, 2024 May 22, 2024

Copy link to clipboard

Copied

Thank you so much for this! Saved me a ton of time!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

(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 at them if the page ranges worked -- I *think* I assumed they were saved in 'the current folder', i.e., the one my test document was in. But InDesign did not do that. After a bit of lateral thinking 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 ...).

Fortuntately, the fix is easy -- just prepend the path of the current file. That leads us to this:

 

//DESCRIPTION:Export page ranges
// A Jongware Script 09-Dec-2019
pglist = prompt ('Page list', '');
exportPreset = '[High Quality Print]';
path = app.activeDocument.fullName.path;
pglist = pglist.split(/,\s*/);
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, app.pdfExportPresets.item(exportPreset));
}

 

Votes

Translate

Translate

Report

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 ,
Dec 09, 2019 Dec 09, 2019

Copy link to clipboard

Copied

No worries at all. Thank you! This works perfectly! I really appreciate your help! 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi, your solution helped me a lot, thanks for sharing it. Is there a way that before generating the PDFs I can select the PDF settings created and saved in InDesign without having to edit the script?

Thank you very much!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

@LMatiel

 

Which options? PDF Preset should be enough?

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hello, I have different settings depending on the job and the printing shop where it is done and being able to choose it would be ideal so as not to be making manual modifications to the script and make a mistake in how to export the PDF.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

@LMatiel

 

You can make multiple copies of the script - name them and set pdf export preset accordingly.

 

Votes

Translate

Translate

Report

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