Adobe 23101764 Scripting Guide - Page 72

Document object

Page 72 highlights

Scripting Photoshop 3 Document object // 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 app.open( fileRef, pdfOpenOptions ); // restore unit settings app.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.9 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. For example, you could use the Document object to get the active layer, save the current document, then copy and paste within the active document or between different documents. 3.9.1 Saving documents and save options Photoshop lets you work with various file formats. It is important to note, however, that the Open and Save formats are not identical. Also note that some formats available in scripting require you to install optional file formats. The optional formats are: • Alias PIX • Electric Image • SGI RGB • Wavefront RLA • SoftImage Photoshop CS Scripting Guide 68

  • 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

Photoshop CS Scripting Guide
68
Scripting Photoshop
Document object
3
// 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
app.open( fileRef, pdfOpenOptions );
// restore unit settings
app.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.9 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.
For example, you could use the
Document
object to get the active layer, save the current
document, then copy and paste within the active document or between different documents.
3.9.1
Saving documents and save options
Photoshop lets you work with various file formats. It is important to note, however, that the
Open
and
Save
formats are not identical.
Also note that some formats available in scripting require you to install optional
le formats.
The optional formats are:
Alias PIX
Electric Image
SGI RGB
Wavefront RLA
SoftImage