Scripting Preview

does anyone out there know if there is a way to give preview commands without driving the GUI like a service or can will it accept a command line ?

Hi,

Preview.app is (a bit) scriptable, but you must enable it manually.
Open the Terminal and type (better copy :wink: ) this:

defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool YES

ok I ran that but I got back some stuff Iā€™ve never seen beforeā€¦ I take it this makes it so I can give it a command from terminal ?

See also: Minimal Scriptability

Edit: mcgrailm, it turns on some very basic AppleScript support.

hmm in either case I am unable to set that value to true as it doesnā€™t seem to exist for that app

what Iā€™m really trying to do is get preview to convert a PS to PDF as pstopdf makes a much llarger file than if I save the PS to PDF from Preview

what about through Xcode is there some way I can get that same result there ?

I donā€™t get any output from that command; Maybe we can help if you post that ā€œstuff.ā€

Do you use Panther?
Then try the boolean value 1 instead of YES

here it is

I think youā€™re missing a space after ā€œwrite.ā€ :slight_smile:

I opened the info.plist and its not there

Can you add it yourself?

no I donā€™t have permission

I thought that would be the case. Unless you can use sudo, youā€™ll have to find a different way to do what you want.

Side note: You typed ā€œScripterā€ instead of ā€œScriptā€

Ok thank you all for your help ā€¦

I knew, why I wrote

:stuck_out_tongue:
:slight_smile:

In 10.7 Info.plists are owned by root:

sudo defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool true sudo chmod 644 /Applications/Preview.app/Contents/Info.plist sudo codesign -f -s - /Applications/Preview.app
Now tell app ā€œPreviewā€ to windows shouldnā€™t cause an error. As in 10.6, Preview still wonā€™t have a dictionary.