Adobe 27510753 - InDesign CS2 - PC Manual page 46

Scripting guide
Hide thumbs Also See for 27510753 - InDesign CS2 - PC:
Table of Contents

Advertisement

38
Getting Started with InDesign Scripting
if(myVerticalJustificationMenu.selectedIndex == 0){
myVerticalJustification = VerticalJustification.topAlign;
}
else if(myVerticalJustificationMenu.selectedIndex == 1){
myVerticalJustification = VerticalJustification.centerAlign;
}
else{
myVerticalJustification = VerticalJustification.bottomAlign;
}
//Get the paragraph alignment setting from the radiobutton group.
if(myRadioButtonGroup.selectedButton == 0){
myParagraphAlignment = Justification.leftAlign;
}
else if(myRadioButtonGroup.selectedButton == 1){
myParagraphAlignment = Justification.centerAlign;
}
else{
myParagraphAlignment = Justification.rightAlign;
}
myDialog.destroy();
//Now create the document and apply the properties to the text.
var myDocument = app.documents.add();
with(myDocument){
var myPage = pages[0];
with(myPage){
}
}
}
else{
myDialog.destroy()
}
//Utility function for getting the bounds of the "live area" of a page.
function myGetBounds(myDocument, myPage){
with(myDocument.documentPreferences){
var myPageHeight = pageHeight;
var myPageWidth = pageWidth;
}
with(myPage.marginPreferences){
var myTop = top;
var myLeft = left;
var myRight = right;
var myBottom = bottom;
}
myRight = myPageWidth - myRight;
myBottom = myPageHeight- myBottom;
return [myTop, myLeft, myBottom, myRight];
}
2. Save the text as a plain text file with the file extension . jsx in the Scripts folder inside the Presets folder in
your InDesign folder.
3. Test the script by double-clicking the script name in the InDesign Scripts palette.
//Create a text frame.
var myTextFrame = pages.item(0).textFrames.add();
with(myTextFrame){
//Set the geometric bounds of the frame using the "myGetBounds" function.
geometricBounds = myGetBounds(myDocument, myPage);
//Set the contents of the frame to the string you entered in the dialog box.
contents = myString;
//Set the alignment of the paragraph.
texts.item(0).justification = myParagraphAlignment;
//Set the point size of the text.
texts.item(0).pointSize = myPointSize;
//Set the vertical justification of the text frame.
textFramePreferences.verticalJustification = myVerticalJustification;
}
Adobe InDesign CS2 Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents