Created
July 15, 2010 00:42
-
-
Save osima/476340 to your computer and use it in GitHub Desktop.
テキストフレームからオーバーフローしたら新しいテキストフレームを追加して連結, InDesign
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// InDesign Extend Script | |
// テキストフレームからオーバーフローしたら新しいテキストフレームを追加して連結. | |
// | |
// 1) テスト用ファイルを開く | |
var testfile = new File("/c/home/test.indd"); | |
app.open( testfile ); | |
var myDoc = app.activeDocument; | |
// 2) テキストフレームが存在していることが前提 | |
var myPage = myDoc.pages.item(0); | |
var tf1 = myPage.textFrames.item(0); | |
// 3) オーバフローが解消されるまでページ追加とテキストフレーム追加および連結を繰り返す | |
while( tf1.overflows ){ | |
// ページを追加 | |
var myPage2 = myDoc.pages.add(); | |
// テキストフレームを作成 | |
var tf2 = createTextFrame(myDoc,myPage2); | |
// 連結 | |
tf1.nextTextFrame = tf2; | |
tf1 = tf2 | |
} | |
// 以下は便利メソッド | |
function createTextFrame(myDoc,myPage){ | |
var myTextFrame=myPage.textFrames.add(); | |
var myBounds = myGetBounds(myDoc,myPage); | |
myTextFrame.geometricBounds=myBounds; | |
return myTextFrame; | |
} | |
function myGetBounds(myDoc, myPage){ | |
with(myDoc.documentPreferences){ | |
var myPageHeight = pageHeight; | |
var myPageWidth = pageWidth; | |
} | |
with(myPage.marginPreferences){ | |
var myTop = top; | |
var myLeft = left; | |
var myRight = right; | |
var myBottom = bottom; | |
} | |
myRight = myPageWidth - myRight; | |
myBottom = myPageHeight- myBottom; | |
return [myTop, myLeft, myBottom, myRight]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment