Skip to main content
rahulb1976
Known Participant
Apr 19, 2018 3:23 PM UTC
Question

Script to Export Multiple PDFs at Once

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

34 replies

Community Expert
Apr 16, 2020 2:24 PM UTC

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 )

 

 

Translate
Participant
Nov 4, 2024 1:27 PM UTC

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

Translate
Robert at ID-Tasker
Legend
Nov 5, 2024 12:43 AM UTC

@Toni340228631gcy

 

What platform, OS and InDesign versions?

 

Translate
Inspiring
Apr 26, 2018 1:22 PM UTC

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

Translate
rahulb1976
Known Participant
Apr 23, 2018 10:47 AM UTC

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

Many thanks

Translate
rahulb1976
Known Participant
Apr 23, 2018 8:37 AM UTC

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

Translate
Peter Kahrel
Community Expert
Community Expert
Apr 23, 2018 8:56 AM UTC

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";

Translate
rahulb1976
Known Participant
Apr 23, 2018 10:04 AM UTC

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

Rahul

Translate
rahulb1976
Known Participant
Apr 20, 2018 2:33 PM UTC

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.

Translate
Peter Kahrel
Community Expert
Community Expert
Apr 20, 2018 3:04 PM UTC

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.

Translate
rahulb1976
Known Participant
Apr 20, 2018 3:21 PM UTC

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

Translate
rahulb1976
Known Participant
Apr 20, 2018 1:03 PM UTC

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?

Translate
Peter Kahrel
Community Expert
Community Expert
Apr 20, 2018 1:27 PM UTC

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.

Translate
rahulb1976
Known Participant
Apr 20, 2018 8:27 AM UTC

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

Translate
Peter Kahrel
Community Expert
Community Expert
Apr 20, 2018 11:38 AM UTC

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

Translate
TᴀW
Legend
Apr 19, 2018 3:30 PM UTC
id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
rahulb1976
Known Participant
Apr 20, 2018 7:21 AM UTC

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.

Translate
Jongware
Community Expert
Community Expert
Apr 20, 2018 8:23 AM UTC

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

Translate