
aborting if the active document was never savedĪlert("active document isn't saved, aborting")
#Create shortcut to save as pdf code#
To get active document path we can use activeDocument.path and to get it's name - activeDocument.name.įull code wrapped in a function: function main() If we put out string in there we can specify the path ourselves.
#Create shortcut to save as pdf pdf#
For example, Save As Pdf generates this: var desc14 = new ActionDescriptor() ĭesc15.putString( stringIDToTypeID('pdfPresetFilename'), "High Quality Print" ) ĭesc15.putInteger( stringIDToTypeID('pdfCompressionType'), 7 ) ĭesc15.putBoolean( stringIDToTypeID('pdfIncludeProfile'), false ) ĭesc14.putObject( charIDToTypeID('As '), charIDToTypeID('PhtP'), desc15 ) ĭesc14.putPath( charIDToTypeID('In '), new File( "D:/my/path/random_name.pdf" ) ) ĭesc14.putInteger( charIDToTypeID('DocI'), 449 ) ĭesc14.putBoolean( charIDToTypeID('Cpy '), true ) ĭesc14.putBoolean( charIDToTypeID('LwCs'), true ) ĭesc14.putBoolean( charIDToTypeID('Lyrs'), false ) ĭesc14.putEnumerated( stringIDToTypeID('saveStage'), stringIDToTypeID('saveStageType'), stringIDToTypeID('saveSucceeded') ) ĮxecuteAction( charIDToTypeID('save'), desc14, DialogModes.NO ) Īll the options that I chose during the save command are written here, for example Lyrs set to false is "No Layers" option. The generated code is quite ugly but it's not very important.

You can use a ScriptingListener Plugin to record most of the things you do in PS as code. On a basic level you could've used Actions to automate these steps, there's one issue though: Action would record an absolute path for your pdf, so having something like "save next to my file" isn't really possible.
