Skip to main content
rahulb1976
Known Participant
April 19, 2018
Question

Script to Export Multiple PDFs at Once

  • April 19, 2018
  • 8 replies
  • 18649 views

Hi All

I’m trying to find out how to export two PDF's at once from Indesign CC. I'm aiming to get 1 PDFx-1a PDF (High res with crop and bleed) and 1 smallest File Size (Cropped, no marks)? Could you point me in the right direction or if anyone has a working script I could use that would be amazing. My brain is going to fall out my ears.

Many thanks

Rahul

8 replies

Community Expert
April 16, 2020

Hi Kepano70,

you say:

 

The script works well to generate pdf-files.
But is it possible to create a jpeg within this script?
I need to create the following several times on a day of 1 InDesign document:
1 HiresPDF
1 Lowres pdf
1 jpeg
For the PDF files, the script works perfectly. But I also want to get a Jpeg file from my InDesign in the same script.

 

Look into Peter Kahrel's Batch Process script where you can save settings:

Batch-process (convert/export/import) documents

https://creativepro.com/files/kahrel/indesign/batch_convert.html

 

Regards,
Uwe Laubender

( ACP )

 

 

Participant
November 4, 2024

Hey guys,

thank you for the great script!

I tried to use it for a jobOption that generate not one PDF of the whole data, it's generating a pdf for every page.
For the first jobOption it works, it gives a folder and puts in all pages in seperate pdf.
So far, so good.

But than he stops and gives this error 

 

But this line is already successfull done.

The following line is:

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset3);

 

 

This is the full script:

// 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 3 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("Schaeffler_HighRes_Einzelseiten");

preset2 = app.pdfExportPresets.itemByName("Schaeffler_LowRes_Einzelseiten");

preset3 = app.pdfExportPresets.itemByName("Schaeffler_LowRes_Einzelseiten");

preset4 = app.pdfExportPresets.itemByName("Schaeffler_LowRes");

if (!(preset1.isValid && preset2.isValid && preset3.isValid && preset4.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$/, "");

// Here you can set the suffix at the end of the name

name1 = thePath+"_HighRes.pdf";

name2 = thePath+"_LowRes.pdf";

name3 = thePath+"_master.pdf";

name4 = thePath+"_master_zusammen.pdf";

d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset3);

d.exportFile(ExportFormat.PDF_TYPE, new File(name4), false, preset4);

 

 

I can't find the mistake 😕😕

Thank you for your help!

 

Kind Regards,

Toni

Robert at ID-Tasker
Legend
November 5, 2024

@Toni340228631gcy

 

What platform, OS and InDesign versions?

 

Inspiring
April 26, 2018

I hope this change in script will help you

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(); } 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 + "_LR.pdf"; name2 = thePath + "_HR.pdf" d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

rahulb1976
Known Participant
April 23, 2018

Thanks guys - Ariel your right I couldn't figure out the bit where I wanted to customise it.

Many thanks

rahulb1976
Known Participant
April 23, 2018

Okay - so the script worked! Yay! however its only creating one pdf - not two and its not renaming _LR _HR. I dont have a clue why it's working completly. Ive created two presets myself Print 1 and Lowres as test presets. Only one is working. See Code. I'm happy to wait on this, but just really need it by the end of this week. So close I can feel it!

d = app.activeDocument;

// Here you can choose the PDF preset

preset1 = app.pdfExportPresets.item ('Print1');

preset2 = app.pdfExportPresets.item ('Lowres');

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.replace(/AW$/, "LR")+".pdf";

name2 = thePath.replace(/AW$/, "HR") +".pdf";

d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

Peter Kahrel
Community Expert
Community Expert
April 23, 2018

Looks as if the script expects the names of the InDesign files to end in AW. Try this:

name1 = thePath + "LR.pdf";

name2 = thePath + "HR.pdf";

rahulb1976
Known Participant
April 23, 2018

Fantastic - Thanks very much for your help! Greatly appreciated!

Rahul

rahulb1976
Known Participant
April 20, 2018

Peter - great work - however can you tell me what im doing wrong. I'm almost there but not sure about the characters for the indesign pdf presets.

d = app.activeDocument;

// Here you can choose the PDF preset

preset1 = app.pdfExportPresets.[HighQualityPrint]("300dpi");

preset2 = app.pdfExportPresets.[Smallest File Size]("100dpi");

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.replace(/AW$/, "LR")+".pdf";

name2 = thePath.replace(/AW$/, "HR") +".pdf";

d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

Cheers for your help so far, greatly appreciated.

Peter Kahrel
Community Expert
Community Expert
April 20, 2018

You'll have to specify PDF presets that exist on your disk. This one:

preset1 = app.pdfExportPresets.[HighQualityPrint]("300dpi");

should be this:

preset1 = app.pdfExportPresets.item ('[High Quality Print]');

and for preset2 you should use a similar format.

(mind the spaces). The ones in Ariel's script are specific for his system (sorry, Ariel, I seem to have hijacked this thread. . .)

P.

rahulb1976
Known Participant
April 20, 2018

Okay - so the script worked! Yay! however its only creating one pdf - not two and its not renaming _LR _HR. I dont have a clue why it's working completley. Ive created two presets myself Print 1 and Lowres as test presets. Only one is working. See Code. I'm happy to wait on this, but just really need it by the end of next week. So close I can feel it!

d = app.activeDocument;

// Here you can choose the PDF preset

preset1 = app.pdfExportPresets.item ('Print1');

preset2 = app.pdfExportPresets.item ('Lowres');

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.replace(/AW$/, "LR")+".pdf";

name2 = thePath.replace(/AW$/, "HR") +".pdf";

d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

rahulb1976
Known Participant
April 20, 2018

Hi Peter thanks for this. If it does work - I know its a silly question but how do I make this work with indesign? I know nothing about scripts - apple or java. Does this script work?

Peter Kahrel
Community Expert
Community Expert
April 20, 2018

Copy the script to InDesign's script folder, then run it from InDesign's Scripts panel. See here for details:

https://indesignsecrets.com/how-to-install-scripts-in-indesign.php

P.

rahulb1976
Known Participant
April 20, 2018

Got an error with it - I don't know anything about scripts, so any help or reconfiguration would be amazing!

// 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("200dpi");

preset2 = app.pdfExportPresets.itemByName("300dpi");

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.replace(/AW$/, "LR")+".pdf";

name2 = thePath.replace(/AW$/, "HR") +".pdf";

d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

Peter Kahrel
Community Expert
Community Expert
April 20, 2018

Looks as if you're treating this as an AppleScript. But it's JavaScript.

TᴀW
Legend
April 19, 2018
Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.
rahulb1976
Known Participant
April 20, 2018

Thank you however I've tried this but the coding is incorrect. Could you resupply it on here? I keep getting an error with it.

Want to test this today 20th April if possible. Many thanks.

Jongware
Community Expert
Community Expert
April 20, 2018

Why not share the error? It may help us help you.