Script : Layers in pdf
Hello to all,
In order to simplify the life of my colleagues, I would like to make a script that exports all the layers of my document in separate pdfs with the name of the layer in the title of my pdfs.
I'm already using the script below which I've cobbled together as best I could (it's not my job, I do what I can). But I don't see how to add the record of each layer automatically.
d = app.activeDocument;
// PDF preset
preset1 = app.pdfExportPresets.itemByName("Print");
preset2 = app.pdfExportPresets.itemByName("Web");
// Date
var today = new Date();
var month = (today.getMonth() + 1) < 10 ? "0"+(today.getMonth() + 1) : (today.getMonth() + 1);
var dateString = (today.getFullYear()+"").substr(2, 2) + "-" + month + "-" + today.getDate();
if (!(preset1.isValid && preset2.isValid)){
alert("Au secours Claire! Vérifier les joboptions.");
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+" Classic - "+dateString+".pdf";
name2 = thePath+" Héritage - "+dateString+".pdf";
name3 = thePath+" Classic - PRINT "+dateString+".pdf";
name4 = thePath+" Héritage - PRINT "+dateString+".pdf";
app.pdfExportPreferences.pageRange = "1,2";
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset2);
app.pdfExportPreferences.pageRange = "3,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);
app.pdfExportPreferences.pageRange = "1,2";
d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset1);
app.pdfExportPreferences.pageRange = "3,4";
d.exportFile(ExportFormat.PDF_TYPE, new File(name4), false, preset1);
If any of you have a solution you would make my life and that of my colleagues much easier.
Thank you very much for your help.
Thanks a lot.
Claire.
