Skip to main content
Claire_Chr
Participating Frequently
October 6, 2020
Answered

Export PDF

  • October 6, 2020
  • 2 replies
  • 896 views

Hello everyone,

 

I'm posting here because I really can't find a solution to my problem.
I have a 4 page indesign file and I would like to export from this document 4 pdf :

1 pdf with pages 1 and 3 in small definition
1 pdf with pages 1 and 3 in high definition
1 pdf with pages 2 and 4 in small definition
1 pdf with pages 2 and 4 in high definition

 

I have a script to save my document in several pdf's of different qualities, but I can't integrate a code to select that certain page. I have tried with colour labels but without success.

 

Here is the script I use to export my pdfs of different qualities.

d = app.activeDocument; 
// Here you can choose the PDF preset 
preset1 = app.pdfExportPresets.itemByName("Print");
preset2 = app.pdfExportPresets.itemByName("Web"); 

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

 

Thank you very much,

Claire

This topic has been closed for replies.
Correct answer Mike Bro

Hello Claire!

Try this for your needs.....

you need to define your pdf names so they don't get over written and also define the page range for each pdf.

d = app.activeDocument; 
// Here you can choose the PDF preset 
preset1 = app.pdfExportPresets.itemByName("Print");
preset2 = app.pdfExportPresets.itemByName("Web"); 

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+"_1&3_print.pdf"; 
name2 = thePath+"_1&3_web.pdf"; 
name3 = thePath+"_2&4_print.pdf"; 
name4 = thePath+"_2&4_web.pdf";

app.pdfExportPreferences.pageRange = "1,3";
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); 
app.pdfExportPreferences.pageRange = "1,3";
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);
app.pdfExportPreferences.pageRange = "2,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset1); 
app.pdfExportPreferences.pageRange = "2,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name4), false, preset2);

Regards,

Mike

2 replies

Mike BroCorrect answer
Legend
October 6, 2020

Hello Claire!

Try this for your needs.....

you need to define your pdf names so they don't get over written and also define the page range for each pdf.

d = app.activeDocument; 
// Here you can choose the PDF preset 
preset1 = app.pdfExportPresets.itemByName("Print");
preset2 = app.pdfExportPresets.itemByName("Web"); 

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+"_1&3_print.pdf"; 
name2 = thePath+"_1&3_web.pdf"; 
name3 = thePath+"_2&4_print.pdf"; 
name4 = thePath+"_2&4_web.pdf";

app.pdfExportPreferences.pageRange = "1,3";
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); 
app.pdfExportPreferences.pageRange = "1,3";
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);
app.pdfExportPreferences.pageRange = "2,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset1); 
app.pdfExportPreferences.pageRange = "2,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name4), false, preset2);

Regards,

Mike

Claire_Chr
Participating Frequently
October 6, 2020

OMG !!! It's perfect ! Thank you so much for your help !!

You've just saved me days of work, you're great!

 

Claire.

SychevKA
Inspiring
October 6, 2020

hi, add this line to your code:

 

app.pdfExportPreferences.pageRange = '1-3'