Всем здраствуйте!
Прошу помощи в нелегком деле написая скриптов под Indesign
Есть скрипт, который экспортирует весь текст из публкации.
А в публикации 40 или 48 страниц и текст со всех страниц не нужен, а нужет с определенных страниц. Порошу всех, кто хоть чем-нибудь может помочь.
Всем огромное спасибо!
Вот исходный код скипта, который экспортирует текст со всех страниц
//ExportAllStories.js
//An InDesign CS JavaScript
//
//Exports all stories in an InDesign document in a specified text format.
//
//For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting.html
//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
//
if(app.documents.length != 0){
if (app.activeDocument.stories.length != 0){
with(myDialog = app.dialogs.addname:"ExportAllStories"})){
//Add a dialog column.
myDialogColumn = dialogColumns.add()
with(myDialogColumn){
with(borderPanels.add()){
staticTexts.addstaticLabel:"Export as:"});
with(myExportFormatButtons = radiobuttonGroups.add()){
radiobuttonControls.addstaticLabel:"Text Only", checkedState:true});
radiobuttonControls.addstaticLabel:"RTF"});
radiobuttonControls.addstaticLabel:"InDesign Tagged Text"});
}
}
}
myReturn = myDialog.show();
if (myReturn == true){
//Get the values from the dialog box.
myExportFormat = myExportFormatButtons.selectedButton;
myDialog.destroy;
myFolder= Folder.selectDialog ("Choose a Folder");
if((myFolder != null)&&(app.activeDocument.stories.length !=0)){
myExportAllStories(myExportFormat, myFolder);
}
}
myDialog.destroy();
}
}
else{
alert("The document does not contain any text. Please open a document containing text and try again.");
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
//myExportStories function takes care of exporting the stories.
//myExportFormat is a number from 0-2, where 0 = text only, 1 = rtf, and 3 = tagged text.
//myFolder is a reference to the folder in which you want to save your files.
function myExportAllStories(myExportFormat, myFolder){
for(myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter++){
myStory = app.activeDocument.stories.item(myCounter);
myID = myStory.id;
switch(myExportFormat){
case 0:
myFormat = ExportFormat.textType;
myExtension = ".txt"
break;
case 1:
myFormat = ExportFormat.RTF;
myExtension = ".rtf"
break;
case 2:
myFormat = ExportFormat.taggedText;
myExtension = ".txt"
break;
}
myFileName = "StoryID" + myID + myExtension;
myFilePath = myFolder + "/" + myFileName;
myFile = new File(myFilePath);
myStory.exportFile(myFormat, myFile);
}
}
Прошу помощи в нелегком деле написая скриптов под Indesign
Есть скрипт, который экспортирует весь текст из публкации.
А в публикации 40 или 48 страниц и текст со всех страниц не нужен, а нужет с определенных страниц. Порошу всех, кто хоть чем-нибудь может помочь.
Всем огромное спасибо!
Вот исходный код скипта, который экспортирует текст со всех страниц
//ExportAllStories.js
//An InDesign CS JavaScript
//
//Exports all stories in an InDesign document in a specified text format.
//
//For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting.html
//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
//
if(app.documents.length != 0){
if (app.activeDocument.stories.length != 0){
with(myDialog = app.dialogs.addname:"ExportAllStories"})){
//Add a dialog column.
myDialogColumn = dialogColumns.add()
with(myDialogColumn){
with(borderPanels.add()){
staticTexts.addstaticLabel:"Export as:"});
with(myExportFormatButtons = radiobuttonGroups.add()){
radiobuttonControls.addstaticLabel:"Text Only", checkedState:true});
radiobuttonControls.addstaticLabel:"RTF"});
radiobuttonControls.addstaticLabel:"InDesign Tagged Text"});
}
}
}
myReturn = myDialog.show();
if (myReturn == true){
//Get the values from the dialog box.
myExportFormat = myExportFormatButtons.selectedButton;
myDialog.destroy;
myFolder= Folder.selectDialog ("Choose a Folder");
if((myFolder != null)&&(app.activeDocument.stories.length !=0)){
myExportAllStories(myExportFormat, myFolder);
}
}
myDialog.destroy();
}
}
else{
alert("The document does not contain any text. Please open a document containing text and try again.");
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
//myExportStories function takes care of exporting the stories.
//myExportFormat is a number from 0-2, where 0 = text only, 1 = rtf, and 3 = tagged text.
//myFolder is a reference to the folder in which you want to save your files.
function myExportAllStories(myExportFormat, myFolder){
for(myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter++){
myStory = app.activeDocument.stories.item(myCounter);
myID = myStory.id;
switch(myExportFormat){
case 0:
myFormat = ExportFormat.textType;
myExtension = ".txt"
break;
case 1:
myFormat = ExportFormat.RTF;
myExtension = ".rtf"
break;
case 2:
myFormat = ExportFormat.taggedText;
myExtension = ".txt"
break;
}
myFileName = "StoryID" + myID + myExtension;
myFilePath = myFolder + "/" + myFileName;
myFile = new File(myFilePath);
myStory.exportFile(myFormat, myFile);
}
}