Hallo Sandra,
versuch es mal damit:
//ExportEachPageWithParaStyleAsPDF.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 = "";
var myParaStyleName = "Name";
var myPDFPresets = app.pdfExportPresets;
var myPDFPresetNames = app.pdfExportPresets.everyItem().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;
myPageTF = myDocument.pages.item(myCounter).textFrames;
myBaseName = "";
oneTF = 0;
while (oneTF < myPageTF.length){
try{
app.findPreferences = app.changePreferences = null;
app.findPreferences.appliedParagraphStyle = myDocument.paragraphStyles.item(myParaStyleName);
myFoundItem = myPageTF[oneTF].texts[0].search("");
}
catch(e){
myFoundItem = "";
}
oneTF += 1;
if (myFoundItem.length != 0){
myBaseName = myFoundItem[0].contents.replace("\r", "").replace("\n", "");
oneTF = myPageTF.length;
}
else{
myRegExp = new RegExp(":","gi");
myPageName = myPageName.replace(myRegExp, "");
myBaseName = "Seite_" + myPageName;
}
}
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.
myFilePath = myFolder + "/" + myBaseName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFPresets.item(myPDFPresetName));
}
}
else{
myDialog.destroy();
}
}
Das Skript sucht in den Textrahmen jeder Seite nach dem Text, der mit dem AF "Name" formatiert ist. Das AF muss im Dokument vorhanden sein und sollte nur einmal je Seite vorkommen. Wird das AF auf einer Seite nicht gefunden, so wird die PDF-Datei mit "Seite_ " + Seitenzahl benannt.