Created
January 8, 2011 16:34
-
-
Save kanemu/770965 to your computer and use it in GitHub Desktop.
[indesign]CSV(二次元配列)の2番目と4番目をフレームに入れる
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
(function(){ | |
/* | |
* 2011.1.8 InDesign Script勉強会お題① | |
* CSV(二次元配列)の2番目と4番目をフレームに入れる | |
*/ | |
var csv = [ | |
["aaa1","bbb1","ccc1","ddd1"], | |
["aaa2","bbb2\rbbb2","ccc2","ddd2"], | |
["aaa3","bbb3","ccc3","ddd3"], | |
["aaa4","bbb4","ccc4","ddd4"], | |
["aaa5","bbb5","ccc5","ddd5"] | |
]; | |
var doc = app.activeDocument; | |
var page = doc.pages[0]; | |
for(var i=0,len=csv.length;i<len;i++){ | |
var tf = page.textFrames.add(); | |
tf.geometricBounds=[10*i,10,10*i+10,60]; | |
tf.contents = [csv[i][1],csv[i][3]].join('\r'); | |
tf.paragraphs[0].appliedParagraphStyle = doc.paragraphStyles.itemByName("a1"); | |
tf.paragraphs[1].appliedParagraphStyle = doc.paragraphStyles.itemByName("a2"); | |
/* | |
* todo:contentsをテキストフレームに入れてからparagraphにスタイルを当てると、改行が入った場合にスタイルがズレる。 | |
* 良い方法はないかな? | |
*/ | |
} | |
alert("処理を終わりました。"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment