Adobe 27510753 Scripting Guide - Page 173

Printing a document, Printing using ranges, Range, PrintPreferences

Page 173 highlights

Adobe InDesign CS2 Scripting Guide Working with Documents in VBScript 165 myBottomMargin + 28, myRightMargin) myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters. idAutoPageNumber myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters.idEmSpace myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters. idSectionMarker myRightFooter.ParentStory.Characters.Item(-1).AppliedCharacterStyle = myDocument. CharacterStyles.Item("page_number") myRightFooter.ParentStory.Paragraphs.Item(1).ApplyStyle myDocument.ParagraphStyles. Item("footer_right"), False Rem Slug information. Set myRightSlug = .TextFrames.Add myRightSlug.ItemLayer = myDocument.Layers.Item("Slug") myRightSlug.GeometricBounds = Array(myDocument.DocumentPreferences.PageHeight + 36, myLeftMargin, myDocument.DocumentPreferences.PageHeight + 144, myRightMargin) myRightSlug.Contents = myString myRightSlug.ParentStory.Texts.Item(1).ConvertToTable Rem Body text master text frame. Set myRightFrame = .TextFrames.Add myRightFrame.ItemLayer = myDocument.Layers.Item("BodyText") myRightFrame.GeometricBounds = Array(.MarginPreferences.Top, .MarginPreferences.Left, myBottomMargin, myRightMargin) myRightFrame.PreviousTextFrame = myLeftFrame End With End With Rem Add section marker text--this text will appear in the footer. myDocument.Sections.Item(1).Marker = "Section 1" Rem When you link the master page text frames, one of the frames Rem sometimes becomes selected. Deselect it. myInDesign.Select idNothingEnum.idNothing Printing a document The following script prints the active document using the current print preferences: Rem PrintDocument.vbs Rem An InDesign CS2 VBScript Rem Prints the active document. Set myInDesign = CreateObject("InDesign.Application.CS2") Rem The PrintOut method has two optional parameters: Rem PrintDialog--if true, display the Print dialog box Rem Using--the printer preset to use. The following line Rem prints the document using the default settings and Rem without displaying the Print dialog box. myInDesign.ActiveDocument.PrintOut False Printing using page ranges To specify a page range to print, set the PageRange property of the document's PrintPreferences object before printing: Rem PrintPageRange.vbs Rem An InDesign CS2 VBScript Rem Prints a page range from the active document. Set myInDesign = CreateObject("InDesign.Application.CS2") Rem Create an example document. Set myDocument = myInDesign.Documents.Add myDocument.ViewPreferences.RulerOrigin = idRulerOrigin.idPageOrigin myPageHeight = myDocument.DocumentPreferences.PageHeight myPageWidth = myDocument.DocumentPreferences.PageWidth myDocument.DocumentPreferences.PagesPerDocument = 10 Set myMasterSpread = myDocument.MasterSpreads.Item(1) Set myTextFrame = myMasterSpread.Pages.Item(1).TextFrames.Add myTextFrame.GeometricBounds = Array(0, 0, myPageHeight, myPageWidth)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

Adobe
InDesign CS2 Scripting Guide
Working with Documents in VBScript
165
myBottomMargin + 28, myRightMargin)
myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters.
idAutoPageNumber
myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters.idEmSpace
myRightFooter.ParentStory.InsertionPoints.Item(1).Contents = idSpecialCharacters.
idSectionMarker
myRightFooter.ParentStory.Characters.Item(-1).AppliedCharacterStyle = myDocument.
CharacterStyles.Item("page_number")
myRightFooter.ParentStory.Paragraphs.Item(1).ApplyStyle myDocument.ParagraphStyles.
Item("footer_right"), False
Rem Slug information.
Set myRightSlug = .TextFrames.Add
myRightSlug.ItemLayer = myDocument.Layers.Item("Slug")
myRightSlug.GeometricBounds = Array(myDocument.DocumentPreferences.PageHeight + 36,
myLeftMargin, myDocument.DocumentPreferences.PageHeight + 144, myRightMargin)
myRightSlug.Contents = myString
myRightSlug.ParentStory.Texts.Item(1).ConvertToTable
Rem Body text master text frame.
Set myRightFrame = .TextFrames.Add
myRightFrame.ItemLayer = myDocument.Layers.Item("BodyText")
myRightFrame.GeometricBounds = Array(.MarginPreferences.Top, .MarginPreferences.Left,
myBottomMargin, myRightMargin)
myRightFrame.PreviousTextFrame = myLeftFrame
End With
End With
Rem Add section marker text--this text will appear in the footer.
myDocument.Sections.Item(1).Marker = "Section 1"
Rem When you link the master page text frames, one of the frames
Rem sometimes becomes selected. Deselect it.
myInDesign.Select idNothingEnum.idNothing
Printing a document
The following script prints the active document using the current print preferences:
Rem PrintDocument.vbs
Rem An InDesign CS2 VBScript
Rem Prints the active document.
Set myInDesign = CreateObject("InDesign.Application.CS2")
Rem The PrintOut method has two optional parameters:
Rem PrintDialog--if true, display the Print dialog box
Rem Using--the printer preset to use. The following line
Rem prints the document using the default settings and
Rem without displaying the Print dialog box.
myInDesign.ActiveDocument.PrintOut False
Printing using page ranges
To specify a page range to print, set the
PageRange
property of the document’s
PrintPreferences
object
before printing:
Rem PrintPageRange.vbs
Rem An InDesign CS2 VBScript
Rem Prints a page range from the active document.
Set myInDesign = CreateObject("InDesign.Application.CS2")
Rem Create an example document.
Set myDocument = myInDesign.Documents.Add
myDocument.ViewPreferences.RulerOrigin = idRulerOrigin.idPageOrigin
myPageHeight = myDocument.DocumentPreferences.PageHeight
myPageWidth = myDocument.DocumentPreferences.PageWidth
myDocument.DocumentPreferences.PagesPerDocument = 10
Set myMasterSpread = myDocument.MasterSpreads.Item(1)
Set myTextFrame = myMasterSpread.Pages.Item(1).TextFrames.Add
myTextFrame.GeometricBounds = Array(0, 0, myPageHeight, myPageWidth)