On Jul 5, 2013, at 7:39 AM, 2551 wrote:
That's why I need to find either an rtf or pdf solution. Either will do, but the pdf version is looking simpler going on current responses from the list, just because TextEdit is such a pain to script. Bash's textutil can't seem to manage more than one 'style' at a timeā¦but I'm willing to consider (any) other solutions, from whatever angle (I would love a scripting solution that doesn't need GUI/Assistive Devices actions, but that's looking increasingly unlikely).
Here's a handler I use to print messages to pdf via Mail.
The Print dialog is standard, so this should also work in Safari, too.
The message is already open in Mail when this handler is called.
on GUIprintToPDF(tempFileName, OSMtLion)
tell application "System Events"
tell process "Mail"
set frontmost to true
-------------------------
keystroke "p" using {command down} -- opens Print dialog
repeat 20 times -- wait for print sheet to appear
delay 1
set frontmost to true
if exists sheet 1 of window 1 then exit repeat
end repeat
if not (exists sheet 1 of window 1) then error "Mail is not responding. The Print dialog failed to appear." --<<<<<
set frontmost to true
-------------------------
set PDFButton to (first menu button of sheet 1 of window 1)
click PDFButton
click menu item 2 of menu 1 of PDFButton -- Save as PDF...
delay 1 -- wait for the Print window
-------------------------
if OSMtLion then
try
set value of text field 1 of sheet 1 of sheet 1 of window 1 to tempFileName --******* for Mt Lion only
on error
error "The pdf document was not created. (in GUIprintToPDF)" --<<<<<<<<<<<<
end try
else
set value of text field 1 of window 1 to tempFileName --******** for Lion and previous
end if
-------------------------
set frontmost to true
keystroke "d" using {command down} -- sets save location to Desktop
keystroke return -- click button "Save"
repeat
delay 1
if not (exists sheet 1 of window 1) then exit repeat
end repeat
end tell
end tell
end GUIprintToPDF ------------------------------------------