Adding Text; Stories And Text Frames - Adobe 0046100128056 - InDesign - Mac Manual

Javascript
Table of Contents

Advertisement

C
6: Text and Type
HAPTER
function myGetBounds(myDocument, myPage){
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myPageHeight = myDocument.documentPreferences.pageHeight
if(myPage.side == PageSideOptions.leftHand){
var myX2 = myPage.marginPreferences.left;
var myX1 = myPage.marginPreferences.right;
}
else{
var myX1 = myPage.marginPreferences.left;
var myX2 = myPage.marginPreferences.right;
}
var myY1 = myPage.marginPreferences.top;
var myX2 = myPageWidth - myX2;
var myY2 = myPageHeight - myPage.marginPreferences.bottom;
return [myY1, myX1, myY2, myX2];
}

Adding text

To add text to a story, use the
insert the text. The following sample script uses this technique to add text at the end of a story (for the
complete script, see AddText):
//Add text at the end of the text in the text frame.
//To do this, we'll use the last insertion point in the story.
//("\r" is a return character.)
var myNewText = "\rThis is a new paragraph of example text.";
myTextFrame.parentStory.insertionPoints.item(-1).contents = myNewText;

Stories and text frames

All text in an InDesign layout is part of a story, and every story can contain one or more text frames.
Creating a text frame creates a story, and stories can contain multiple text frames.
In the preceding script, we added text at the end of the parent story rather than at the end of the text
frame. This is because the end of the text frame might not be the end of the story; that depends on the
length and formatting of the text. By adding the text to the end of the parent story, we can guarantee that
the text is added, regardless of the composition of the text in the text frame.
You always can get a reference to the story using the
useful to work with the text of a story instead of the text of a text frame; the following script demonstrates
the difference. The alerts shows that the text frame does not contain the overset text, but the story does
(for the complete script, see StoryAndTextFrame).
property of the insertion point at the location where you want to
contents
property of a text frame. It can be
parentTextFrame
Entering and Importing Text 72

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents