Adobe 23101764 Scripting Guide - Page 20
JavaScript Sample Code, Hello World
UPC - 718659340025
View all Adobe 23101764 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 20 highlights
Scripting basics 2 Object Model JavaScript Sample Code This code contains JavaScript commands that instruct Photoshop to remember current unit settings and then create a new document with height and width in inches. An art layer created within the document is then changed to a text layer, whose contents are set to "Hello World!". References are released after the script is run and original ruler unit settings are restored. var originalUnit = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.INCHES; var docRef = app.documents.add( 4, 2, 72, "Hello, World!"); var artLayerRef = docRef.artLayers.add(); artLayerRef.kind = LayerKind.TEXT; var textItemRef = artLayerRef.textItem; textItemRef.contents = "Hello, World!"; docRef = null; artLayerRef = null; textItemRef = null; app.preferences.rulerUnits = originalUnit; Hello World Aside from minor differences in display format, all three scripts produce the message illustrated below. NOTE: The remainder of this chapter provides information about general scipting tips and techniques. Experienced AppleScript writers and Visual Basic and JavaScript programmers may want to skip to Chapter 3 for specifics on scripting Photoshop. Photoshop CS Scripting Guide 16