Adobe 65010248 Scripting Guide - Page 44
Working with selections, Selecting artwork objects, Working with text frames, Threaded frames
UPC - 883919156484
View all Adobe 65010248 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 44 highlights
CHAPTER 5: Scripting with JavaScript Working with text frames 44 Working with selections When the user makes a selection in a document, the selected objects are stored in the document's selection property. To access all selected objects in the active document: var selectedObjects = app.activeDocument.selection; The selection property value can be an array of any type of art objects, depending on what types of objects are selected. To get or manipulate the properties of the selected art items, you must retrieve the individual items in the array. To find out an object's type, use the typename property. The following sample gets the first object in the array, then displays the object's type: var topObject = app.activeDocument.selection[0]; alert(topObject.typename) The first object in a selection array is the selected object that was last added to the page, not the last object selected. Selecting artwork objects To select an art object, use the object's selected property. Working with text frames To create a text frame of a specific type in JavaScript, use the textFrames method whose name corresponds to the text frame's type; for example: var rectRef = docRef.pathItems.rectangle(700, 50, 100, 100); //use the areaText method to create the text frame var areaTextRef = docRef.textFrames.areaText(rectRef); Threaded frames As in the Illustrator application, you can thread area text frames or path text frames. To thread existing text frames, use the nextFrame or previousFrame property of the text frame object. When copying the following script to the ESTK, place the value of the contents property on one line. var myDoc = documents.add(); var myPathItem1 = myDoc.pathItems.rectangle(244, 64, 82, 76); var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1); var myPathItem2 = myDoc.pathItems.rectangle(144, 144, 42, 116); var myTextFrame2 = myDoc.textFrames.areaText(myPathItem2); // use the nextFrame property to thread the text frames myTextFrame1.nextFrame = myTextFrame2; var sText = "This is two text frames linked together as one story, with text flowing from the first to the last. This is two text frames linked together as one story, with text flowing from the first to the last. This is two text frames linked together as one story. "; myTextFrame1.contents = sText; redraw();