Adobe 27510753 Scripting Guide - Page 36
Save the text as a plain text file with the file extension
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 36 highlights
28 Getting Started with InDesign Scripting Adobe InDesign CS2 Scripting Guide 6. Save the form. 7. Click the button you created in Step 3 to run the new script. JavaScript 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. Enter the following JavaScript in a new text file. //Improved Hello World! //Enter the name of a font on your system, if necessary. myFont = app.fonts.item("Arial"); var myDocument = app.activeDocument with(myDocument){ var myPage = pages.item(0); var myBounds = myGetBounds(myPage,myDocument); with(myDocument.pages.item(0)){ //Get a reference to the text frame. var myTextFrame = textFrames.item(0); //Change the size of the text frame. myTextFrame.geometricBounds = myBounds; var myParagraph = myTextFrame.paragraphs.item(0); myParagraph.appliedFont = myFont; myParagraph.justification = Justification.leftAlign; myParagraph.pointZSize = 48; } } //myGetBounds calculates and return the bounds of the "live area" of the page. function myGetBounds(myPage, myDocument){ var array = new Array() var item = 0; with (myDocument.documentPreferences){ var myPageHeight = pageHeight; var myPageWidth = pageWidth; } with(myPage.marginPreferences){ var myX1 = left; var myY1 = top; var myY2 = bottom; var myX2 = right; } array[item++] = myY1; array[item++] = myX1; array[item++] = myPageHeight - myY2; array[item++] = myPageWidth - myX2; return array; } 3. 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. 4. Run the new script by double-clicking the script name in the InDesign Scripts palette.