activate application "TextEdit"
tell application "System Events"
tell process "TextEdit"
-- insert GUI Scripting statements here
keystroke "p" using command down
set PDFButton to menu button "PDF" of sheet 1 of window 1
click PDFButton
click menu item "Save As PDF…" of menu 1 of PDFButton
delay 1
click button "Save" of window 1
end tell
end tell
The ellipsis in "Save as PDF..." is the ellipsis character, not three periods.
Filling in the Name field of the Save dialog is left as an exercise.
This runs on Mac OS X 10.7.2 Lion. I vaguely recall that I wrote a script just like this once before, so it probably works on earlier versions, too.
On Jan 9, 2012, at 4:48 PM, R. Nelson Byrne wrote:
Is there a way using AppleScript or Automator to print to PDF?