Adobe 0046100128056 Scripting Guide - Page 89
Splitting all frames in a story, Creating an anchored frame
UPC - 718659087562
View all Adobe 0046100128056 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 89 highlights
CHAPTER 6: Text and Type Working with Text Frames 89 Splitting all frames in a story The following script fragment shows how to split all frames in a story into separate, independent stories, each containing one unlinked text frame (for the complete script, see SplitStory): if(app.documents.length != 0){ if(app.selection.length != 0){ //Get the first item in the selection. var mySelection = app.selection[0]; //Process the selection. If text or a text frame is //selected, do something; otherwise, do nothing. switch(mySelection.constructor.name){ case "Text": case "InsertionPoint": case "Character": case "Word": case "Line": case "TextStyleRange": case "Paragraph": case "TextColumn": case "TextFrame": //If the text frame is the only text frame in the story, do nothing. if(mySelection.parentStory.textContainers.length != 1){ //Splitting the story is a two-step process: first, duplicate //the text frames, second, delete the original text frames. mySplitStory(mySelection.parentStory); myRemoveFrames(mySelection.parentStory); } break; } } } Here is the mySplitStory function referred to in the preceding script: function mySplitStory(myStory){ var myTextFrame; //Duplicate each text frame in the story. for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){ myTextFrame = myStory.textContainers[myCounter]; myTextFrame.duplicate(); } } function myRemoveFrames(myStory){ //Remove each text frame in the story. Iterate backwards to //avoid invalid references. for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){ myStory.textContainers[myCounter].remove(); } } Creating an anchored frame To create an anchored frame (also known as an inline frame), you can create a text frame (or rectangle, oval, polygon, or graphic line) at a specific location in text (usually an insertion point). The following script fragment shows an example (for the complete script, see AnchoredFrame):