- Registriert
- 03.08.06
- Beiträge
- 183
An alle, die sich mit (Java)script und InDesign auskennen mal eine (für mich) ganz vertrackte Fragestellung:
Ich mache per Datenzusammenführung im ID CS3 ein paar hundert Visitenkarten. Jetzt soll - vor dem Druck - jeder einzelne seine PDF nochmal kontrollieren.
Ein Script, das jede Seite einzeln als durchnummerierte PDF-Datei speichert, hab ich schon gefunden (im Anschluss)
Jetzt muss ein armes Würstchen alle PDFs per E-Mail an alle Adressaten schicken zwecks Imprimatur.
Jetzt mal meine Vision: Ein weiteres Script wertet das Feld mit der E-Mail Adresse aus und sendet - Trommelwirbel - die entsprechende PDF (weiterer Trommelwirbel) AU-TO-MA-TISCH (Applaus!!!) unter Verwendung eines Standard-Anschreibens ab!
Wahnsinn, oder? Aber zumindest wäre es toll, wenn jemand das folgende Script so erweitern kann, dass ein bestimmtes Feld (z.B. der Name) als Bestandteil des Dateinamens der erzeugten PDF benutzt würde.
Hier das Script:
//ExportEachPageAsPDF.js
//Exports each page of an InDesign CS document as a separate PDF to
//a selected folder using the selected PDF export settings.
//Display a "choose folder" dialog box.
if(app.documents.length != 0){
var myFolder = Folder.selectDialog ("Choose a Folder");
if(myFolder != null){
myExportPages(myFolder);
}
}
else{
alert("Please open a document and try again.");
}
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myPDFPresets = app.pdfExportPresets;
var myPDFPresetNames = new Array;
for (i = 0; i < myPDFPresets.length; i++)
myPDFPresetNames.push(myPDFPresets.name);
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()) {
staticTexts.add({staticLabel:"Base name:", minWidth:130});
}
with(dialogColumns.add()) {
var myBaseNameField = textEditboxes.add({editContents:myDocumentName, minWidth:160});
}
}
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"PDF preset: ", minWidth:130});
}
with(dialogColumns.add()){
var myPDFPresetsDropdown = dropdowns.add({stringList:myPDFPresetNames, selectedIndex:0});
}
}
}
var myResult = myDialog.show({name:"ExportPages"});
if(myResult == true){
var myBaseName = myBaseNameField.editContents;
var myPDFPresetName = myPDFPresetNames[myPDFPresetsDropdown.selectedIndex];
//Remove the dialog box from memory.
myDialog.destroy();
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
myPageName = myDocument.pages.item(myCounter).name;
app.pdfExportPreferences.pageRange = myPageName;
//The name of the exported files will be the base name + the page name + ".pdf".
//If the page name contains a colon (as it will if the document contains sections),
//then remove the colon.
var myRegExp = new RegExp(":","gi");
myPageName = myPageName.replace(myRegExp, "_");
myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFPresets.item(myPDFPresetName));
}
}
else{
myDialog.destroy();
}
}
Ich mache per Datenzusammenführung im ID CS3 ein paar hundert Visitenkarten. Jetzt soll - vor dem Druck - jeder einzelne seine PDF nochmal kontrollieren.
Ein Script, das jede Seite einzeln als durchnummerierte PDF-Datei speichert, hab ich schon gefunden (im Anschluss)
Jetzt muss ein armes Würstchen alle PDFs per E-Mail an alle Adressaten schicken zwecks Imprimatur.
Jetzt mal meine Vision: Ein weiteres Script wertet das Feld mit der E-Mail Adresse aus und sendet - Trommelwirbel - die entsprechende PDF (weiterer Trommelwirbel) AU-TO-MA-TISCH (Applaus!!!) unter Verwendung eines Standard-Anschreibens ab!
Wahnsinn, oder? Aber zumindest wäre es toll, wenn jemand das folgende Script so erweitern kann, dass ein bestimmtes Feld (z.B. der Name) als Bestandteil des Dateinamens der erzeugten PDF benutzt würde.
Hier das Script:
//ExportEachPageAsPDF.js
//Exports each page of an InDesign CS document as a separate PDF to
//a selected folder using the selected PDF export settings.
//Display a "choose folder" dialog box.
if(app.documents.length != 0){
var myFolder = Folder.selectDialog ("Choose a Folder");
if(myFolder != null){
myExportPages(myFolder);
}
}
else{
alert("Please open a document and try again.");
}
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myPDFPresets = app.pdfExportPresets;
var myPDFPresetNames = new Array;
for (i = 0; i < myPDFPresets.length; i++)
myPDFPresetNames.push(myPDFPresets.name);
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()) {
staticTexts.add({staticLabel:"Base name:", minWidth:130});
}
with(dialogColumns.add()) {
var myBaseNameField = textEditboxes.add({editContents:myDocumentName, minWidth:160});
}
}
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"PDF preset: ", minWidth:130});
}
with(dialogColumns.add()){
var myPDFPresetsDropdown = dropdowns.add({stringList:myPDFPresetNames, selectedIndex:0});
}
}
}
var myResult = myDialog.show({name:"ExportPages"});
if(myResult == true){
var myBaseName = myBaseNameField.editContents;
var myPDFPresetName = myPDFPresetNames[myPDFPresetsDropdown.selectedIndex];
//Remove the dialog box from memory.
myDialog.destroy();
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
myPageName = myDocument.pages.item(myCounter).name;
app.pdfExportPreferences.pageRange = myPageName;
//The name of the exported files will be the base name + the page name + ".pdf".
//If the page name contains a colon (as it will if the document contains sections),
//then remove the colon.
var myRegExp = new RegExp(":","gi");
myPageName = myPageName.replace(myRegExp, "_");
myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFPresets.item(myPDFPresetName));
}
}
else{
myDialog.destroy();
}
}