Adobe 23101335 Scripting Guide - Page 54

Document object, Dim docRef As Photoshop.Document

Page 54 highlights

Scripting Photoshop 3 Document object pdfOpenOptionsRef.Width = 200 pdfOpenOptionsRef.mode = psOpenRGB pdfOpenOptionsRef.Resolution = 72 pdfOpenOptionsRef.ConstrainProportions = False 'Now open the file Dim docRef As Photoshop.Document Set docRef = appRef.Open(< a file path>, pdfOpenOptionsRef) 'Restore unit setting appRef.Preferences.RulerUnits = originalRulerUnits JS: // Set the ruler units to pixels var originalRulerUnits = preferences.rulerUnits; preferences.rulerUnits = Units.PIXELS; // Get a reference to the file that we want to open var fileRef = new File( < a file path > ); // Create a PDF option object var pdfOpenOptions = new PDFOpenOptions; pdfOpenOptions.antiAlias = true; pdfOpenOptions.height = 100; pdfOpenOptions.width = 200; pdfOpenOptions.mode = OpenDocumentMode.RGB; pdfOpenOptions.resolution = 72; pdfOpenOptions.constrainProportions = false; // Now open the file open( fileRef, pdfOpenOptions ); // restore unit settings preferences.rulerUnits = originalRulerUnits; Because Photoshop cannot save all of the format types that it can open, the open document types may be different from the save document types. 3.8 Document object After you target the Photoshop application, the next object you will likely target is the Document object. The Document object can represent any open document in Photoshop. Photoshop 7.0 Scripting Guide 54

  • 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

Photoshop 7.0 Scripting Guide
54
Scripting Photoshop
Document object
3
pdfOpenOptionsRef.Width = 200
pdfOpenOptionsRef.mode = psOpenRGB
pdfOpenOptionsRef.Resolution = 72
pdfOpenOptionsRef.ConstrainProportions = False
'Now open the file
Dim docRef As Photoshop.Document
Set docRef = appRef.Open(< a file path>, pdfOpenOptionsRef)
'Restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
JS:
// Set the ruler units to pixels
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
// Get a reference to the file that we want to open
var fileRef = new File( < a file path > );
// Create a PDF option object
var pdfOpenOptions = new PDFOpenOptions;
pdfOpenOptions.antiAlias = true;
pdfOpenOptions.height = 100;
pdfOpenOptions.width = 200;
pdfOpenOptions.mode = OpenDocumentMode.RGB;
pdfOpenOptions.resolution = 72;
pdfOpenOptions.constrainProportions = false;
// Now open the file
open( fileRef, pdfOpenOptions );
// restore unit settings
preferences.rulerUnits = originalRulerUnits;
Because Photoshop cannot save all of the format types that it can open, the open document
types may be different from the save document types.
3.8 Document object
After you target the Photoshop application, the next object you will likely target is the
Document
object. The
Document
object can represent any open document in Photoshop.