Adobe 27510753 Scripting Guide - Page 33
Adding features to “Hello World
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 33 highlights
Adobe InDesign CS2 Scripting Guide Getting Started with InDesign Scripting 25 Adding features to "Hello World" Next, let's create a new script that makes changes to the "Hello World" publication that we created with our first script. Our second script demonstrates how to: l Get the active document. l Use a function (or handler in AppleScript). l Get the page dimensions and page margins of the active publication. l Resize a text frame. l Change the formatting of the text in the text frame. After reformatting, the document page resembles the following: AppleScript To create the script: 1. Make sure that you have the Hello World document open; if you've closed the document without saving it, simply run the previous script again to make a new Hello World document. 2. Choose File > New in the Script Editor to create a new script. 3. Enter the following code: --Improved "Hello World" tell application "Adobe InDesign CS2" --Get a reference to a font. try --Enter the name of a font on your system, if necessary. set myFont to font "Helvetica" end try --Get the active document and assign the result to the variable "myDocument." set myDocument to active document tell myDocument --Use the handler "myGetBounds" to get the bounds of the --"live area" inside the margins of page 1. set myBounds to my myGetBounds(myDocument, page 1) tell text frame 1 of page 1 --Resize the text frame to match the page margins. set geometric bounds to myBounds tell paragraph 1 --Change the font, size, and paragraph alignment. try set applied font to myFont end try set point size to 72