Adobe 27510753 Scripting Guide - Page 174

Setting print preferences

Page 174 highlights

166 Working with Documents in VBScript Adobe InDesign CS2 Scripting Guide myTextFrame.Contents = idSpecialCharacters.idAutoPageNumber myTextFrame.Paragraphs.Item(1).Justification = idJustification.idCenterAlign myTextFrame.Paragraphs.Item(1).PointSize = 72 myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign Set myTextFrame = myMasterSpread.Pages.Item(2).TextFrames.Add myTextFrame.GeometricBounds = Array(0, 0, myPageHeight, myPageWidth) myTextFrame.Contents = idSpecialCharacters.idAutoPageNumber myTextFrame.Paragraphs.Item(1).Justification = idJustification.idCenterAlign myTextFrame.Paragraphs.Item(1).PointSize = 72 myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign For myCounter = 1 To myDocument.Pages.Count myDocument.Pages.Item(myCounter).AppliedMaster = myDocument.MasterSpreads.Item("A-Master") Next Rem End of example document setup. Rem The page range can be either idPageRange.idAllPages or a page range string. Rem A page number entered in the page range must correspond to a page Rem name in the document (i.e., not the page index). If the page name is Rem not found, InDesign will display an error message. myInDesign.ActiveDocument.PrintPreferences.PageRange = "1-3, 6, 9" myInDesign.ActiveDocument.PrintOut False Setting print preferences The PrintPreferences object contains properties corresponding to the options in the panels of the Print dialog box. This example script shows how to set print preferences using scripting: Rem PrintPreferences.vbs Rem An InDesign CS2 VBScript Rem Sets the print preferences of the active document. Set myInDesign = CreateObject("InDesign.Application.CS2") With myInDesign.ActiveDocument.PrintPreferences Rem Properties corresponding to the controls in the General panel of the Print dialog box. Rem ActivePrinterPreset is ignored in this example--we'll set our own print preferences. Rem printer can be either a string (the name of the printer) or idPrinter.idPostscriptFile. .Printer = "AGFA-SelectSet 5000SF v2013.108" Rem If the printer property is the name of a printer, then the ppd property Rem is locked (and will return an error if you try to set it). Rem ppd = "AGFA-SelectSet5000SF" Rem If the printer property is set to Printer.postscript file, the copies Rem property is unavailable. Attempting to set it will generate an error. .Copies = 1 Rem If the printer property is set to Printer.postscript file, or if the Rem selected printer does not support collation, then the collating Rem property is unavailable. Attempting to set it will generate an error. Rem collating = false .ReverseOrder = False Rem pageRange can be either PageRange.allPages or a page range string. .PageRange = idPageRange.idAllPages .PrintSpreads = False .PrintMasterPages = False Rem If the printer property is set to Printer.postScript file, then Rem the printFile property contains the file path to the output file. Rem printFile = "/c/test.ps" .Sequence = idSequences.idAll Rem If trapping is set to either idTrapping.idApplicationBuiltIn or idTrapping.idAdobeInRIP, Rem then setting the following properties will produce an error. If (.ColorOutput = idColorOutputModes.idInRIPSeparations) Or _ (.ColorOutput = idColorOutputModes.idSeparations) Then If .Trapping = idTrapping.idOff Then .PrintBlankPages = False .PrintGuidesGrids = False .PrintNonprinting = False End If End If Rem Rem Properties corresponding to the controls in the Setup panel of the Print dialog box.

  • 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

166
Working with Documents in VBScript
Adobe InDesign CS2 Scripting Guide
myTextFrame.Contents = idSpecialCharacters.idAutoPageNumber
myTextFrame.Paragraphs.Item(1).Justification = idJustification.idCenterAlign
myTextFrame.Paragraphs.Item(1).PointSize = 72
myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign
Set myTextFrame = myMasterSpread.Pages.Item(2).TextFrames.Add
myTextFrame.GeometricBounds = Array(0, 0, myPageHeight, myPageWidth)
myTextFrame.Contents = idSpecialCharacters.idAutoPageNumber
myTextFrame.Paragraphs.Item(1).Justification = idJustification.idCenterAlign
myTextFrame.Paragraphs.Item(1).PointSize = 72
myTextFrame.TextFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign
For myCounter = 1 To myDocument.Pages.Count
myDocument.Pages.Item(myCounter).AppliedMaster = myDocument.MasterSpreads.Item("A-Master")
Next
Rem End of example document setup.
Rem The page range can be either idPageRange.idAllPages or a page range string.
Rem A page number entered in the page range must correspond to a page
Rem name in the document (i.e., not the page index). If the page name is
Rem not found, InDesign will display an error message.
myInDesign.ActiveDocument.PrintPreferences.PageRange = "1-3, 6, 9"
myInDesign.ActiveDocument.PrintOut False
Setting print preferences
The
PrintPreferences
object contains properties corresponding to the options in the panels of the Print
dialog box. This example script shows how to set print preferences using scripting:
Rem PrintPreferences.vbs
Rem An InDesign CS2 VBScript
Rem Sets the print preferences of the active document.
Set myInDesign = CreateObject("InDesign.Application.CS2")
With myInDesign.ActiveDocument.PrintPreferences
Rem Properties corresponding to the controls in the General panel of the Print dialog box.
Rem ActivePrinterPreset is ignored in this example--we’ll set our own print preferences.
Rem printer can be either a string (the name of the printer) or idPrinter.idPostscriptFile.
.Printer = "AGFA-SelectSet 5000SF v2013.108"
Rem If the printer property is the name of a printer, then the ppd property
Rem is locked (and will return an error if you try to set it).
Rem ppd = "AGFA-SelectSet5000SF"
Rem If the printer property is set to Printer.postscript file, the copies
Rem property is unavailable. Attempting to set it will generate an error.
.Copies = 1
Rem If the printer property is set to Printer.postscript file, or if the
Rem selected printer does not support collation, then the collating
Rem property is unavailable. Attempting to set it will generate an error.
Rem collating = false
.ReverseOrder = False
Rem pageRange can be either PageRange.allPages or a page range string.
.PageRange = idPageRange.idAllPages
.PrintSpreads = False
.PrintMasterPages = False
Rem If the printer property is set to Printer.postScript file, then
Rem the printFile property contains the file path to the output file.
Rem printFile = "/c/test.ps"
.Sequence = idSequences.idAll
Rem If trapping is set to either idTrapping.idApplicationBuiltIn or idTrapping.idAdobeInRIP,
Rem then setting the following properties will produce an error.
If (.ColorOutput = idColorOutputModes.idInRIPSeparations) Or _
(.ColorOutput = idColorOutputModes.idSeparations) Then
If .Trapping = idTrapping.idOff Then
.PrintBlankPages = False
.PrintGuidesGrids = False
.PrintNonprinting = False
End If
End If
Rem --------------------------------------------------------------------------------
Rem Properties corresponding to the controls in the Setup panel of the Print dialog box.