EDOBE XDOM TPC Technical Information Page 48

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 47
CHAPTER 5: Scripting with JavaScript Working with text frames 48
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 objects type, use the
typename property.
The following sample gets the first object in the array, then displays the objects 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 frames 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();
Page view 47
1 2 ... 43 44 45 46 47 48 49 50 51 52 53 ... 67 68

Comments to this Manuals

No comments