Welcome! 登入 註冊
美寶首頁 美寶百科 美寶論壇 美寶落格 美寶地圖

Advanced

Programming of InDesign in Javascript - the duplicate method of textFrame

(1) meaning: ducplicate a textFrame


(2)syntax: duplicate( to, by)
Each parameter can be omitted, and both parameters can be omitted simultaneously.
"to" means the place you want to duplicate to. It can be spread, layer, page. That is, the spread, lay, or page you want to dulpicate to.
The meaning of "by" is a little complicated. It is a 2-tuple consisting of 2 number, like (10,20).
(a) If "to" parameter has been assigned, "by" means the relative position of the new textFrame to the old textFrame.
(b) If "to" parameter is omitted, "by" means the absolute postion of upper-left corner of the new textFrame.


(3)Example:

(a)
myDoc = app.documents.add(); //"app" means the Indesign program. This statement establishs a new document in Indesign. We call this new document myDoc.
myPage = myDoc.pages[0]; //When a new document is established, an empty new page in this document is created automatically. This new page is referred to as pages[0] by default in Indesign object model. In this statement, we call this new page myPage.
myTextFrame = myPage.textFrames.add() //This statedment establishs a new textframe in myPage, and we call this new textframe myTetFrame.
myTextFrame.geometricBounds = [ 100,100,200,200] ;
//geometricBoudns = [a , b , c, d ]
//a is the y coordinate of the up bound of the textframe.
//b is the x coordinate of the left bound of the textframe.
//c is the y coordinate of the lower bound of the textframe.
//d is the x coordinate of the right bound of the textframe.
//i.e.,the coordinate of the up-left corner of the textframe is (b,a)

myTextFrame.dupllicate() //Both parameters are omitted simultaneously, So,a textframe of the same size with the old textframe would be duplicated in the same position of the same page.



(b)
myPage= app.documents.add().pages[0]; //This statement is an abbreviated form of the first and second statements in the above example.
myTextFrame = myPage.textFrames.add()
myTextFrame.geometricBounds = [ 100,100,200,200] ;
myTextFrame.dupllicate( [10,20] )

In the 4-th statement, the "to" parameter is omitted, so the value [10,20] of the "by" parameters" is an absolute postion. That is, the cooridinate of the upper-left corner of the new textframe is [10,20] and the its geometricBounds is [20,10,120,110]. The page that the new textframe is placed in is the same page with that of the old textframe due to the lack of the "to" parameter.


-- to be continued -----



Edited 16 time(s). Last edit at 08/05/2010 10:15PM by RandomVariable.
(編輯記錄)