Adobe 27510753 Scripting Guide - Page 94

Creating a preset using new values, To create a document preset using explicit values

Page 94 highlights

86 Working with Documents in AppleScript Adobe InDesign CS2 Scripting Guide --DocumentPresetByExample.as --An InDesign CS2 AppleScript --Creates a new document preset based on the current document settings. tell application "Adobe InDesign CS2" if (count documents) > 0 then set myDocument to active document --If the document preset "myDocumentPreset" does not already exist, create it. try set myDocumentPreset to document preset "myDocumentPreset" on error set myDocumentPreset to make document preset with ¬ properties {name:"myDocumentPreset"} end try --Fill in the properties of the document preset with the corresponding --properties of the active document. tell myDocumentPreset --Note that the following gets the page margins from the margin preferences --of the document; to get the margin preferences from the active page, --replace "myDocument" with "active page of active window" in the --following line (assuming the active window is a layout window). set myMarginPreferences to margin preferences of myDocument set left to left of myMarginPreferences set right to right of myMarginPreferences set top to top of myMarginPreferences set bottom to bottom of myMarginPreferences set column count to column count of myMarginPreferences set column gutter to column gutter of myMarginPreferences set document bleed bottom offset to document bleed bottom offset ¬ of document preferences of myDocument set document bleed top offset to document bleed top offset ¬ of document preferences of myDocument set document bleed inside or left offset to document bleed inside ¬ or left offset of document preferences of myDocument set document bleed outside or right offset to document bleed outside ¬ or right offset of document preferences of myDocument set facing pages to facing pages of document preferences of myDocument set page height to page height of document preferences of myDocument set page width to page width of document preferences of myDocument set page orientation to page orientation of document preferences ¬ of myDocument set pages per document to pages per document of document preferences ¬ of myDocument set slug bottom offset to slug bottom offset of document preferences ¬ of myDocument set slug top offset to slug top offset of document preferences of myDocument set slug inside or left offset to slug inside or left offset ¬ of document preferences of myDocument set slug right or outside offset to slug right or outside offset ¬ of document preferences of myDocument end tell end if end tell Creating a preset using new values To create a document preset using explicit values, run the following script: --DocumentPreset.as --An InDesign CS2 AppleScript --Creates a new document preset. tell application "Adobe InDesign CS2" --If the document preset "myDocumentPreset" does not already exist, create it. try set myDocumentPreset to document preset "myDocumentPreset" on error set myDocumentPreset to make document preset ¬

  • 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

86
Working with Documents in AppleScript
Adobe InDesign CS2 Scripting Guide
--DocumentPresetByExample.as
--An InDesign CS2 AppleScript
--Creates a new document preset based on the current document settings.
tell application "Adobe InDesign CS2"
if (count documents) > 0 then
set myDocument to active document
--If the document preset "myDocumentPreset" does not already exist, create it.
try
set myDocumentPreset to document preset "myDocumentPreset"
on error
set myDocumentPreset to make document preset with
¬
properties {name:"myDocumentPreset"}
end try
--Fill in the properties of the document preset with the corresponding
--properties of the active document.
tell myDocumentPreset
--Note that the following gets the page margins from the margin preferences
--of the document; to get the margin preferences from the active page,
--replace "myDocument" with "active page of active window" in the
--following line (assuming the active window is a layout window).
set myMarginPreferences to margin preferences of myDocument
set left to left of myMarginPreferences
set right to right of myMarginPreferences
set top to top of myMarginPreferences
set bottom to bottom of myMarginPreferences
set column count to column count of myMarginPreferences
set column gutter to column gutter of myMarginPreferences
set document bleed bottom offset to document bleed bottom offset
¬
of document preferences of myDocument
set document bleed top offset to document bleed top offset
¬
of document preferences of myDocument
set document bleed inside or left offset to document bleed inside
¬
or left offset of document preferences of myDocument
set document bleed outside or right offset to document bleed outside
¬
or right offset of document preferences of myDocument
set facing pages to facing pages of document preferences of myDocument
set page height to page height of document preferences of myDocument
set page width to page width of document preferences of myDocument
set page orientation to page orientation of document preferences
¬
of myDocument
set pages per document to pages per document of document preferences ¬
of myDocument
set slug bottom offset to slug bottom offset of document preferences
¬
of myDocument
set slug top offset to slug top offset of document preferences of myDocument
set slug inside or left offset to slug inside or left offset
¬
of document preferences of myDocument
set slug right or outside offset to slug right or outside offset
¬
of document preferences of myDocument
end tell
end if
end tell
Creating a preset using new values
To create a document preset using explicit values, run the following script:
--DocumentPreset.as
--An InDesign CS2 AppleScript
--Creates a new document preset.
tell application "Adobe InDesign CS2"
--If the document preset "myDocumentPreset" does not already exist, create it.
try
set myDocumentPreset to document preset "myDocumentPreset"
on error
set myDocumentPreset to make document preset
¬