Adobe 27510753 Scripting Guide - Page 138

Printing using ranges, Setting print preferences, property of the document's

Page 138 highlights

130 Working with Documents in JavaScript Adobe InDesign CS2 Scripting Guide myRightSlug.parentStory.tables.add(); //Body text master text frame. var myRightFrame = textFrames.add(myDocument.layers.item("BodyText"), undefined, undefined, {geometricBounds:[marginPreferences.top, marginPreferences.left, myBottomMargin, myRightMargin], previousTextFrame:myLeftFrame}); } } //Add section marker text--this text will appear in the footer. myDocument.sections.item(0).marker = "Section 1"; //When you link the master page text frames, one of the frames sometimes becomes selected. Deselect it. app.select(NothingEnum.nothing, undefined); Printing a document The following script prints the active document using the current print preferences: //PrintDocument.jsx //An InDesign CS2 JavaScript //Prints the active document. app.activeDocument.print(); Printing using page ranges To specify a page range to print, set the pageRange property of the document's printPreferences object before printing: //PrintPageRange.jsx //An InDesign CS2 JavaScript //Prints a page range from the active document. //Assumes that you have a document open, that it contains a page named "22". //The page range can be either PageRange.allPages or a page range string. //A page number entered in the page range must correspond to a page //name in the document (i.e., not the page index). If the page name is //not found, InDesign will display an error message. app.activeDocument.printPreferences.pageRange = "22" app.activeDocument.print(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: //PrintPreferences.jsx //An InDesign CS2 JavaScript //Sets the print preferences of the active document. with(app.activeDocument.printPreferences){ //Properties corresponding to the controls in the General panel //of the Print dialog box. activePrinterPreset is ignored in this //example--we'll set our own print preferences. printer can be //either a string (the name of the printer) or Printer.postscriptFile. printer = "AGFA-SelectSet 5000SF v2013.108"; //If the printer property is the name of a printer, then the ppd property //is locked (and will return an error if you try to set it). //ppd = "AGFA-SelectSet5000SF"; //If the printer property is set to Printer.postscript file, the copies //property is unavailable. Attempting to set it will generate an error. copies = 1; //If the printer property is set to Printer.postscript file, or if the //selected printer does not support collation, then the collating //property is unavailable. Attempting to set it will generate an error. //collating = false;

  • 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

130
Working with Documents in JavaScript
Adobe InDesign CS2 Scripting Guide
myRightSlug.parentStory.tables.add();
//Body text master text frame.
var myRightFrame = textFrames.add(myDocument.layers.item("BodyText"), undefined, undefined,
{geometricBounds:[marginPreferences.top, marginPreferences.left, myBottomMargin, myRightMargin],
previousTextFrame:myLeftFrame});
}
}
//Add section marker text--this text will appear in the footer.
myDocument.sections.item(0).marker = "Section 1";
//When you link the master page text frames, one of the frames sometimes becomes selected. Deselect
it.
app.select(NothingEnum.nothing, undefined);
Printing a document
The following script prints the active document using the current print preferences:
//PrintDocument.jsx
//An InDesign CS2 JavaScript
//Prints the active document.
app.activeDocument.print();
Printing using page ranges
To specify a page range to print, set the
pageRange
property of the document’s
printPreferences
object
before printing:
//PrintPageRange.jsx
//An InDesign CS2 JavaScript
//Prints a page range from the active document.
//Assumes that you have a document open, that it contains a page named "22".
//The page range can be either PageRange.allPages or a page range string.
//A page number entered in the page range must correspond to a page
//name in the document (i.e., not the page index). If the page name is
//not found, InDesign will display an error message.
app.activeDocument.printPreferences.pageRange = "22"
app.activeDocument.print(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:
//PrintPreferences.jsx
//An InDesign CS2 JavaScript
//Sets the print preferences of the active document.
with(app.activeDocument.printPreferences){
//Properties corresponding to the controls in the General panel
//of the Print dialog box. activePrinterPreset is ignored in this
//example--we’ll set our own print preferences. printer can be
//either a string (the name of the printer) or Printer.postscriptFile.
printer = "AGFA-SelectSet 5000SF v2013.108";
//If the printer property is the name of a printer, then the ppd property
//is locked (and will return an error if you try to set it).
//ppd = "AGFA-SelectSet5000SF";
//If the printer property is set to Printer.postscript file, the copies
//property is unavailable. Attempting to set it will generate an error.
copies = 1;
//If the printer property is set to Printer.postscript file, or if the
//selected printer does not support collation, then the collating
//property is unavailable. Attempting to set it will generate an error.
//collating = false;