Skip to main content
Claire_Chr
Participating Frequently
October 6, 2020
解決済み

Export PDF

  • October 6, 2020
  • 返信数 2.
  • 896 ビュー

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

このトピックへの返信は締め切られました。
解決に役立った回答 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

Mike Bro解決!
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
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'