TOP > blog > 18.インデザインスクリプト 初級講座(14)まとめ
インデザインスクリプト
2016/02/12

18.インデザインスクリプト 初級講座(14)まとめ

管理者用
blog

インデザインのスクリプト 初級講座で使用した機能をまとめました。

表への機能は、初級講座(13) を参照してください。、


Set myInDesign = CreateObject("InDesign.Application.CC_J") 'インデザインを起動

ドキュメント作成


Set myDocument = myInDesign.Documents.Add 'ドキュメント作成

ドキュメントサイズをセットする。


Me_size_GH = 297
Me_size_GY = 210
With myDocument.DocumentPreferences
.PageHeight = CStr(Me_size_GH) & "mm"
        .PageWidth = CStr(Me_size_GY) & "mm"
        .FacingPages = False
'***************************************
Rem 裁ち落とし
        .DocumentBleedBottomOffset = "3p"
        .DocumentBleedTopOffset = "3p"
        .DocumentBleedInsideOrLeftOffset = "3p"
        .DocumentBleedOutsideOrRightOffset = "3p"
Rem 印刷可能領域
        .SlugBottomOffset = "20mm"
        .SlugTopOffset = "20mm"
        .SlugInsideOrLeftOffset = "20mm"
        .SlugRightOrOutsideOffset = "20mm"
End With

ドキュメントを保存します。


myInDesign.ActiveDocument.Save INDD_name

ドキュメントを閉じます


myInDesign.ActiveDocument.Close

ドキュメントを開き


Set myDocument = myInDesign.Open(INDD_name)

テキストフレームを作る


Set myTextFrame = myDocument.TextFrames.Add

テキストフレームサイズを設定する


haichi_1_YS = 100
haichi_1_XS = 20
haichi_1_YE = 150
haichi_1_XE = 180
myTextFrame.GeometricBounds = Array(CStr(haichi_1_YS) + "mm", CStr(haichi_1_XS) + "mm", CStr(haichi_1_YE) + "mm", CStr(haichi_1_XE) + "mm")

テキストフレームに文字を書き込む


myTextFrame.Contents = "岩手県盛岡市山田6-7-8"

後ろに追加して書き込む


myTextFrame.ParentStory.InsertionPoints.Item(-1).Contents = vbCr & "電 話03ー3785ー4402"

テキストフレームを回転


myTextFrame.RotationAngle = 90

テキストフレームを拡大/縮小 横


myTextFrame.HorizontalScale = 50

テキストフレームを拡大/縮小 縦


myTextFrame.VerticalScale = 200

テキストフレームを傾ける


myTextFrame.ShearAngle = 30

テキストフレームの移動


mov_XS = 40
mov_YS = 150
myTextFrame.Move Array(CStr(mov_XS), CStr(mov_YS))

フォントの指定

 
myTextFrame.ParentStory.AppliedFont = "MS ゴシック"
myTextFrame.ParentStory.FontStyle = "Regular"

フォントサイズの指定


font_P = 20
myTextFrame.ParentStory.PointSize = CStr(font_P)

行間を指定する。


myTextFrame.ParentStory.Leading = 24

文字間を変える


myTextFrame.ParentStory.Tracking = 100

長体/平体


myTextFrame.ParentStory.HorizontalScale = 120

長体/平体


myTextFrame.ParentStory.VerticalScale = 150

段落の配置位置を指定する


myTextFrame.ParentStory.Justification = idJustification.idRightAlign

'idAwayFromBindingSide = 1633772147 (&H61616273)
'idCenterAlign = 1667591796 (&H63656E74)
'idCenterJustified = 1667920756 (&H636A7374)'中央
'idFullyJustified = 1718971500 (&H66756C6C)'両端
'idLeftAlign = 1818584692 (&H6C656674)
'idLeftJustified = 1818915700 (&H6C6A7374)
'idRightAlign = 1919379572 (&H72676874)'末
'idRightJustified = 1919578996 (&H726A7374)
'idToBindingSide = 1630691955 (&H61326273)

行配置モードを指定する


myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign '  1667591796 (&H63656E74)'中央

'idBottomAlign = 1651471469 (&H626F746D)'行下揃え
'idCenterAlign = 1667591796 (&H63656E74)'中央
'idJustifyAlign = 1785951334 (&H6A737466)'両端そろえ
'idTopAlign = 1953460256 (&H746F7020)'トップ

インデントの指定


myTextFrame.Paragraphs.Item(2).FirstLineIndent = "10mm"

文字のベースラインを指定する


myTextFrame.Characters(2).BaselineShift = "2pt"
myTextFrame.Paragraphs.Item(2).BaselineShift = "4pt"

段落の削除


myTextFrame.Paragraphs(2).Delete

文字の削除


myTextFrame.Characters(2).Delete

段落 文字の削除


myTextFrame.Paragraphs(2).Characters(2).Delete

文字のアウトラインを作成する


'フレーム
myTextFrame.CreateOutlines (False) '元データを残す
myTextFrame.CreateOutlines (True)

'何文字目が字指定
myTextFrame.Characters(2).CreateOutlines (True)

'何行目か指定
myTextFrame.Paragraphs.Item(2).CreateOutlines (True)

タブの設定


Set myTabStop1 = myTextFrame.ParentStory.TabStops.Add
myTabStop1.Alignment = idTabStopAlignment.idLeftAlign
myTabStop1.Position = 20

'行指定でタブのセット
Set myTabStop1 = myTextFrame.Paragraphs(4).TabStops.Add
myTabStop1.Position = 10

'リーダーの設定
myTabStop1.Leader = "・"

'タブのリセット
myTabStop1.Delete

'タブ  キャラクターセット
myTabStop21.AlignmentCharacter = "×"

'タブの種類
'idTabStopAlignment.idCenterAlign = 1667591796
'idTabStopAlignment.idCharacterAlign = 1952604515
' idTabStopAlignment.idLeftAlign = 1818584692
'idTabStopAlignment.idRightAlign = 1919379572

字取り


Set myStartCharacter = myTextFrame.ParentStory.Paragraphs.Item(2).Characters.Item(1)
Set myEndCharacter = myTextFrame.ParentStory.Paragraphs.Item(2).Characters.Item(3)
myTextFrame.Texts.ItemByRange(myStartCharacter, myEndCharacter).Item(1).Jidori = 9

縦中横


Set myStartCharacter = myTextFrame.ParentStory.Paragraphs.Item(2).Characters.Item(6)
Set myEndCharacter = myTextFrame.ParentStory.Paragraphs.Item(2).Characters.Item(7)
myTextFrame.Texts.ItemByRange(myStartCharacter, myEndCharacter).Item(1).Tatechuyoko = True

フレーム オーバフロー


Ovef= myTextFrame.Overflows

行数と、折り返された見た目の行数


L_cunt = myTextFrame.ParentStory.Paragraphs.Count
G_cunt = myTextFrame.Lines.Count

'目的行の行数(フレームで折り返されている?)
Set myStartCharacter = myTextFrame.ParentStory.Paragraphs.Item(tyoutai_gyo)
Set myEndCharacter = myTextFrame.ParentStory.Paragraphs.Item(tyoutai_gyo)
lincounA = myTextFrame.Texts.ItemByRange(myStartCharacter, myEndCharacter).Item(1).Lines.Count

画像ファイルの取り込み


haichi_1_YS = 100
haichi_1_XS = 20
haichi_1_YE = 150
haichi_1_XE = 180
myTextFrame.GeometricBounds = Array(CStr(haichi_1_YS) + "mm", CStr(haichi_1_XS) + "mm", CStr(haichi_1_YE) + "mm", CStr(haichi_1_XE) + "mm")
myTextFrame.ContentType = idContentType.idGraphicType '1735553140
myTextFrame.Place ("gazFile.jpg")

'フレームを画像にフィット
myTextFrame1.Fit (idFitOptions.idFrameToContent) '1718906723
'myTextFrame1.Fit idFitOptions.idContentToFrame '1668575078
'myTextFrame1.Fit (idFitOptions.idFrameToContent) '1718906723
  'idContentToFrame = 1668575078 (&H63746F66)
 'idApplyFrameFittingOptions = 1634100847 (&H6166666F)
 'idCenterContent = 1667591779 (&H63656E63)
 'idFillProportionally = 1718185072 (&H66696C70)
 'idFrameToContent = 1718906723 (&H66746F63)
 'idProportionally = 1668247152 (&H636F6E70)

ファイルをオープン、クローズのテンプレート


'***********************************************************************
FilleName = "ファイル名"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Err.Number = 0 Then
    Set objFile = objFSO.OpenTextFile(FilleName)
        If Err.Number = 0 Then
        '====================================
         Rem データ読み込み                            ========
        '===============================
    
            Do While objFile.AtEndOfStream <> True
                strValue = objFile.ReadLine  '1行づつ読込
Rem 読み込んだデータの処理を記述
            '==================================================
            '==================================================
            '==================================================
            '==================================================
            '==================================================
            '==================================================
            '==================================================
            '==================================================
                            
            Loop
        '===============================
            objFile.Close
Rem ファイルクローズ後の処理を記述
            '==================================================
            '==================================================
            '==================================================
            '==================================================
Else
            WScript.Echo "ファイルオープンエラー: " & Err.Description
        End If
Else
        WScript.Echo "エラー: " & Err.Description
    End If
Set objFile = Nothing
    Set objFSO = Nothing
'***********************************************************************

PDFファイル読込


myFileName = "kawasemi.pdf"
myInDesign.PDFPlacePreferences.PageNumber = STpege
Set myTextFrame = myDocument.Pages.Item(outpege).TextFrames.Add
haichi_1_YS = 0
haichi_1_XS = 0
haichi_1_YE = 105
 haichi_1_XE = 148
 myTextFrame.GeometricBounds = Array(CStr(haichi_1_YS) + "mm", CStr(haichi_1_XS) + "mm", CStr(haichi_1_YE) + "mm", CStr(haichi_1_XE) + "mm")
Set myPDFset = myTextFrame.Place(myFileName) 'Array(-6, -20))

Set myPDFset = myPDFset.Item(1)
actpag = myPDFset.PDFAttributes.PageNumber

 

 

関連記事