Article View: adobe.scripting.indesign
Article #9722Re: applying label to a spread
From: Olav_Kvern
Date: Fri, 21 Jul 2006 14:44
Date: Fri, 21 Jul 2006 14:44
61 lines
4128 bytes
4128 bytes
Hi Martin--
re: "[Dave wrote] I don't think there's any way for a user to see that particular label"
Of course there is! Here's a script that presents a dialog where the user can enter a label:
//SetSpreadLabel.jsx
//An InDesign CS2 JavaScript
//
//Sets the label of a specified spread.
main();
function main(){
if(app.documents.length != 0){
myDisplayDialog();
}
}
function myDisplayDialog(){
var mySpread, myString;
var myLabelWidth = 60;
var myFieldWidth = 200;
var mySpreadNames = new Array;
var myDocument = app.documents.item(0);
for(var myCounter = 0; myCounter < myDocument.spreads.length; myCounter++){
mySpread = myDocument.spreads.item(myCounter);
myString = ""
for(myPageCounter = 0; myPageCounter < mySpread.pages.length; myPageCounter++){
myString = myString + mySpread.pages.item(myPageCounter).name;
if(myPageCounter<mySpread.pages.length -1){ myString = myString + ", "; } } mySpreadNames.push(myString); } var myDialog = app.dialogs.add({name:"SetSpreadLabel"}); with(myDialog.dialogColumns.add()){ with(dialogRows.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Spread:", minWidth:myLabelWidth}); } with(dialogColumns.add()){ var mySpreadsDropdown = dropdowns.add({stringList:mySpreadNames, minWidth:myFieldWidth, selectedIndex:0}); } } with(dialogRows.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Label:", minWidth:myLabelWidth}); } with(dialogColumns.add()){ var myLabelField = textEditboxes.add({editContents:"Enter Spread Label", minWidth:myFieldWidth}); } } } var myResult = myDialog.show(); if(myResult == true){ var mySpreadIndex = mySpreadsDropdown.selectedIndex; var myLabel = myLabelField.editContents; myDialog.destroy(); myDocument.spreads.item(mySpreadIndex).label = myLabel; } else{ myDialog.destroy(); } }
...and here's the corresponding script for displaying a spread label:
//GetSpreadLabel.jsx
//An InDesign CS2 JavaScript
//
//Gets the label of a specified spread.
main();
function main(){
if(app.documents.length != 0){
myDisplayDialog();
}
}
function myDisplayDialog(){
var mySpread, myString;
var myLabelWidth = 60;
var myFieldWidth = 200;
var mySpreadNames = new Array;
var myDocument = app.documents.item(0);
for(var myCounter = 0; myCounter < myDocument.spreads.length; myCounter++){
mySpread = myDocument.spreads.item(myCounter);
myString = ""
for(myPageCounter = 0; myPageCounter < mySpread.pages.length; myPageCounter++){
myString = myString + mySpread.pages.item(myPageCounter).name;
if(myPageCounter<mySpread.pages.length -1){ myString = myString + ", "; } } mySpreadNames.push(myString); } var myDialog = app.dialogs.add({name:"GetSpreadLabel"}); with(myDialog.dialogColumns.add()){ with(dialogRows.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Spread:", minWidth:myLabelWidth}); } with(dialogColumns.add()){ var mySpreadsDropdown = dropdowns.add({stringList:mySpreadNames, minWidth:myFieldWidth, selectedIndex:0}); } } } var myResult = myDialog.show(); if(myResult == true){ var mySpreadIndex = mySpreadsDropdown.selectedIndex; myDialog.destroy(); alert("Spread label is: " + myDocument.spreads.item(mySpreadIndex).label); } else{ myDialog.destroy(); } }
Thanks,
Ole
Technical Details
Message-ID:
<3bc0fbdf.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.motzarella.org!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc0fbdf.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,d90bcf137b1933fc X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Olav_Kvern@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: applying label to a spread Message-ID: <3bc0fbdf.2@webcrossing.la2eafNXanI> Date: Fri, 21 Jul 2006 07:44:24 -0700 References: <3bc0fbdf.-1@webcrossing.la2eafNXanI> Lines: 126 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.motzarella.org!news.ecp.fr!news.stben.net!webcrossing