Adobe 0046100128056 Scripting Guide - Page 145

Processing a Profile

Page 145 highlights

CHAPTER 10: Working with Preflight Processing a Profile 145 //Requires the page size to be 8.5in x 11in (Letter Size) //enters a value for tolerance myRule.ruleDataObjects.add("tolerance", RuleDataType.realDataType, 0.01); //Sets the width to the point equivalent of 8.5 inches myRule.ruleDataObjects.add("width", RuleDataType.realDataType, 612); //Sets the width to the point equivalent of 11 inches myRule.ruleDataObjects.add("height", RuleDataType.realDataType, 792); //true = ignore orientation is checked myRule.ruleDataObjects.add("ignore_orientation", RuleDataType.booleanDataType, true); 3. Set the rule's reporting state. This is done using the rule's flag property. There are several choices (disabled, information, warning, and error), controlled by the PreflightRuleFlag enumeration. //set the rule to return an error myRule.flag = PreflightRuleFlag.returnAsError; Processing a Profile In the desktop version of InDesign, preflight errors are reported in the user interface. In scripting (especially for InDesign Server), the errors are generated on demand. The following script processes an InDesign document. (For the complete script, see ProcessPreflightProfile.) If there are errors, it writes the results to a new PDF file. For an example of the output, see the figure below the script. // Assume there is a document. var myDoc = app.documents.item(0); // Assume the Test preflight profile exists. var myProfile = app.preflightProfiles.itemByName("Test"); //Process the myDoc with the rule var myProcess = app.preflightProcesses.add(myDoc, myProfile); myProcess.waitForProcess(); var myResults = myProcess.processResults; //If errors were found if (myResults != "None") { //Export the file to PDF. The "true" value selects to open the file after export. myProcess.saveReport(File("C:\PreflightResults.pdf"), true); } //Cleanup myProcess.remove();

  • 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
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209

C
HAPTER
10: Working with Preflight
Processing a Profile
145
//Requires the page size to be 8.5in x 11in (Letter Size)
//enters a value for tolerance
myRule.ruleDataObjects.add("tolerance", RuleDataType.realDataType, 0.01);
//Sets the width
to the point equivalent of 8.5 inches
myRule.ruleDataObjects.add("width", RuleDataType.realDataType, 612);
//Sets the width
to the point equivalent of 11 inches
myRule.ruleDataObjects.add("height", RuleDataType.realDataType, 792);
//true = ignore orientation is checked
myRule.ruleDataObjects.add("ignore_orientation", RuleDataType.booleanDataType,
true);
3.
Set the rule’s reporting state.
This is done using the rule’s
flag
property. There are several choices (disabled, information, warning,
and error), controlled by the
PreflightRuleFlag
enumeration.
//set the rule to return an error
myRule.flag = PreflightRuleFlag.returnAsError;
Processing a Profile
In the desktop version of InDesign, preflight errors are reported in the user interface. In scripting
(especially for InDesign Server), the errors are generated on demand. The following script processes an
InDesign document. (For the complete script, see ProcessPreflightProfile.) If there are errors, it writes the
results to a new PDF file. For an example of the output, see the figure below the script.
// Assume there is a document.
var myDoc = app.documents.item(0);
// Assume the Test preflight profile exists.
var myProfile = app.preflightProfiles.itemByName("Test");
//Process the myDoc with the rule
var myProcess = app.preflightProcesses.add(myDoc, myProfile);
myProcess.waitForProcess();
var myResults = myProcess.processResults;
//If errors were found
if (myResults != "None")
{
//Export the file to PDF. The "true" value selects to open the file after export.
myProcess.saveReport(File("C:\PreflightResults.pdf"), true);
}
//Cleanup
myProcess.remove();