2009-09-01から1ヶ月間の記事一覧

テキストフレーム(ストーリー)に文字のサイズ、行送り、書体、行揃えを設定する

var frame = app.activeDocument.selection[0]; frame.parentStory.pointSize = "13q"; frame.parentStory.leading = "20ha"; frame.parentStory.justification = Justification.rightAlign; frame.parentStory.appliedFont = app.fonts.item("小塚ゴシック …

二分探索っぽくオーバーフロー処理をしてみたサンプル

#target "InDesign" myDoc = app.documents.add(); frame = myDoc.textFrames.add(); frame.geometricBounds = ["0","0","5","50"]; frame.parentStory.contents = "吾輩(わがはい)は猫である。名前はまだ無い。";//関数呼び出し if(chotai(frame,60)) ale…

現在の日付、時刻を取得

var d = new Date(); alert(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());d.getFullYear() //年 d.getMonth() + 1 //月(なぜか前月が入るので+1) d.getDate()…

単位の変更

[JavaScript] var myDoc = app.activeDocument; //定規の水平方向 myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS; //定規の垂直方向 myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS; …

選択したフレームにスクリプトラベルを設定する

[JavaScript] var frame = app.activeDocument.selection[0]; frame.label = "画像枠";[VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) frame.label = "画像枠"※参考 スクリプトラベルが設定されて…

InDesign JavaScript内の正規表現

var phone = "電話番号 03-1234-9876"; phone = phone.replace(/([0-9]+)-([0-9]+)-([0-9]+)/g,"($1)$3-$2"); - phoneの中 : 電話番号 (03)9876-1234以下の様に記述することも出来る phone = phone.replace(RegExp("([0-9]+)-([0-9]+)-([0-9]+)","g"),"($1)$…

フレームの移動

1.ドキュメントの座標値で移動 (配列で [横座標 , 縦座標] ) [JavaScript] var frame = app.activeDocument.selection[0]; frame.move ([10,10]);[VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(…

引数を取得する

//InDesign Desktop版でVBSのDoScriptから引数を取得する場合 arguments[0] //InDesign Serverの場合 var id = app.scriptArgs.get("id")引数の名前で取得できます。サンプルの場合は id という名前で引数値を取得しています。

オーバーフローしたテキストを長体で押し込む

[JavaScript] var frame = app.activeDocument.selection[0]; try{ while(frame.overflows){ frame.parentStory.horizontalScale = frame.parentStory.horizontalScale - 1; } }catch(e){ frame.parentStory.horizontalScale = 100; alert("長体かけまくりま…

テキストフレームのオーバーフロー(溢れ)値を取得する

[JavaScript] var frame = app.activeDocument.selection[0]; alert(frame.overflows);[VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) msgbox frame.overflowsオーバーフローしている場合 True オ…

グラフィックス化(アウトライン化)

[JavaScript] var frame = app.activeDocument.selection[0]; frame.createOutlines();[VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) frame.createOutlines()※注意 アンダーラインとか使っている…

Glyph(グリフ)検索置換

[JavaScript] app.changeGlyphPreferences = NothingEnum.nothing; app.findGlyphPreferences = NothingEnum.nothing;app.findGlyphPreferences.appliedFont = app.fonts.item("A-OTF 新ゴ Pro M"); app.findGlyphPreferences.glyphID = 7565; app.changeGly…

テキストフレームのフィットオプション

テキストに合せてフレームが行方向に伸び縮みします。[JavaScript] var frame = app.activeDocument.selection[0]; frame.fit(FitOptions.FRAME_TO_CONTENT);[VBScript] Set app = CreateObject("InDesign.Application") Const idFrameToContent = 171890672…

画像フレームのフィットオプション

画像をフレームピッタリに配置したり、逆に画像に合せてフレームを大きくしたり小さくしたり。[JavaScript] var frame = app.activeDocument.selection[0]; frame.place(File("/c/sample.jpg")); frame.fit(FitOptions.CONTENT_TO_FRAME); [VBScript] Set ap…

画像フレームの揃え(フレーム調整オプション、基準点)の変更

[JavaScript] var frame = app.activeDocument.selection[0]; frame.frameFittingOptions.fittingAlignment = AnchorPoint.TOP_CENTER_ANCHOR; frame.place(File("/c/sample.jpg")); [VBScript] Set app = CreateObject("InDesign.Application") Const idBot…

フレーム全体の行揃えを変更する

[JavaScript] var frame = app.activeDocument.selection[0]; frame.parentStory.justification = Justification.rightAlign; [VBScript] Set app = CreateObject("InDesign.Application") Const idRightAlign = 1919379572 Set frame = app.activeDocument.…

フレーム全体の行送りを変更する

[JavaScript] var frame = app.activeDocument.selection[0]; frame.parentStory.leading = 30; [VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) frame.parentStory.leading = 30

フレーム削除

[JavaScript] var frame = app.activeDocument.selection[0]; frame.remove(); [VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) frame.delete()

スクリプトラベルが設定されているフレームを選択する

[JavaScript] var myDoc = app.activeDocument; frame = myDoc.pages.item(0).pageItems.item("画像枠"); [VBScript] Set app = CreateObject("InDesign.Application") Set myDoc = app.ActiveDocument Set frame = myDoc.pages.item(1).pageItems.item("画…

EPS形式で保存

[JavaScript] var myDoc = app.activeDocument; myDoc.exportFile(ExportFormat.EPS_TYPE, File("/c/sample.eps")); [VBScript] Set app = CreateObject("InDesign.Application") Const idEPSType = 1952400720 Set myDoc = app.ActiveDocument myDoc.Export…

テキスト検索置換

[JavaScript] app.changeTextPreferences = NothingEnum.nothing; app.findTextPreferences = NothingEnum.nothing; app.findTextPreferences.findWhat = "これを"; app.changeTextPreferences.changeTo = "アレニ"; app.changeTextPreferences.appliedFont …

フォルダ削除

[JavaScript] var DeleteFolder = new Folder("/c/Sample/"); DeleteFolder.remove();

ファイル保存

[JavaScript] var myDoc = app.activeDocument; myDoc = myDoc.save(File("/c/sample.indd")); [VBScript] Set app = CreateObject("InDesign.Application") Set myDoc = app.ActiveDocument myDoc.save("C:/sample.indd") 保存しないで閉じる場合は [JavaSc…

フレームサイズの取得

[JavaScript] var frame = app.activeDocument.selection[0]; var y = frame.visibleBounds[0]; //左上 y var x = frame.visibleBounds[1]; //左上 x var y1 = frame.visibleBounds[2]; //右下 y1 var x1 = frame.visibleBounds[3]; //右下 x1 [VBScript] Se…

フレームサイズの変更

[JavaScript] var frame = app.activeDocument.selection[0]; frame.visibleBounds = ["10","10","100","100"]; [VBScript] Set app = CreateObject("InDesign.Application") Set frame = app.activeDocument.selection(1) frame.visibleBounds = Array(10,1…

画像フレームの作成

[JavaScript] frame = myDoc.textFrames.add(); frame.contentType = ContentType.GRAPHIC_TYPE; [VBScript] Set app = CreateObject("InDesign.Application") Const idGraphicType = 1735553140 Set myDoc = app.ActiveDocument Set frame = myDoc.textFram…

テキストフレームの作成

[JavaScript] var myDoc = app.activeDocument; frame = myDoc.textFrames.add(); [VBScript] Set app = CreateObject("InDesign.Application") Set myDoc = app.ActiveDocument Set frame = myDoc.textFrames.add()

ドキュメントサイズの変更

[JavaScript] var myDoc = app.activeDocument; myDoc.documentPreferences.pageWidth = "150mm"; myDoc.documentPreferences.pageHeight = "150mm"; [VBScript] Set app = CreateObject("InDesign.Application") Set myDoc = app.ActiveDocument myDoc.docu…

新規ドキュメント作成

[JavaScript] myDoc = app.documents.add(); [VBScript] Set app = CreateObject("InDesign.Application.CS3_J") Set myDoc = app.Documents.add()

ファイルを開く

[JavaScript] myDoc = app.open(File("/c/sample.indt")); [VBScript] Set app = CreateObject("InDesign.Application.CS3_J") Set myDoc = app.Open("C:/sample.indt")