REQUIREMENTS:
A droplet/app that converts any (iWork 08/09) .pages .numbers .keynote file dragged onto it into a PDF, and then attaches the resulting PDF file to a new Entourage email msg.
OPTIONAL:
Resulting PDF is automatically trashed from the HD once the email msg is sent.
BONUS: If the Droplet/app could convert .doc and .xls to PDFs also, that would be huge.
AWESOME: If the droplet could convert ANY format to PDF and attach it to a new email- FANTASTIC!
NOTES
I found a script - (referenced below) that does the conversion, and saves the output PDF to the desktop. Currently you have to drag the output PDF from the desktop to the dock icon for Entourage to attach it to a new msg and then you have to trash the file once you have sent the msg. I would like to fully automate the process, since it is done frequently. My thought is to add to this script the attaching to Entourage, and change the output PDF location to a Temp folder whose contents get automatically trashed after hours (that can be a separate folder action script.)
The current script is saved as an app and dragged to the finder toolbar for easy access-files can be browsed and dragged over the icon in the toolbar and converted.
===================START SCRIPT===========
on open theFiles
-- check to see which iWork apps are running to begin with
set pagesRunning to false
set numbersRunning to false
set keynoteRunning to false
tell application "System Events"
if exists process "Pages" then set pagesRunning to true
if exists process "Numbers" then set numbersRunning to true
if exists process "Keynote" then set keynoteRunning to true
end tell
set pagesStarted to pagesRunning
set numbersStarted to numbersRunning
set keynoteStarted to keynoteRunning
repeat with aFile in theFiles
-- prepare name manipulation
set theInfo to (info for (aFile))
set theExtension to name extension of (theInfo)
set theName to name of (theInfo)
set theOriginalName to theName
-- remove extension
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "." & theExtension as string
set theName to first text item of theName
set AppleScript's text item delimiters to prevTIDs
-- prepare desktop folder path and name
set myDesktop to (path to desktop folder) as Unicode text
set docPathAndName to myDesktop & theName & ".pdf"
-- cases for conversions
if (theExtension is equal to "pages") then -- Pages to Word
tell application "Pages"
-- check if document is already open
set targetDocument to null
repeat with aDoc in documents
if (name of aDoc) is equal to theOriginalName then set targetDocument to aDoc
end repeat
-- if not, open it
if targetDocument is null then
open aFile
set fileOpened to true
set targetDocument to front document
else
set fileOpened to false
end if
-- convert it
save targetDocument as "SLDocumentTypePDF" in docPathAndName
-- close it if necessary
if fileOpened then close targetDocument saving no
end tell
set pagesStarted to true
else if (theExtension is equal to "numbers") then -- Numbers to Excel
tell application "Numbers"
-- check if document is already open
set targetDocument to null
repeat with aDoc in documents
if (name of aDoc) is equal to theOriginalName then set targetDocument to aDoc
end repeat
-- if not, open it
if targetDocument is null then
open aFile
set fileOpened to true
set targetDocument to front document
else
set fileOpened to false
end if
-- convert it
save targetDocument as "LSDocumentTypePDF" in docPathAndName
-- close it if necessary
if fileOpened then close targetDocument saving no
end tell
set numbersStarted to true
else if (theExtension is equal to "key") then -- Keynote to PPT
-- delete the file, if it exists, so it can be recreated
tell application "Finder"
if docPathAndName exists then delete docPathAndName
end tell
-- now make sure Keynote has the file open
tell application "Keynote"
-- check if document is already open
set targetDocument to null
repeat with aDoc in slideshows
if (name of aDoc) is equal to theOriginalName then set targetDocument to aDoc
activate targetDocument
end repeat
-- if not, open it
if targetDocument is null then
open aFile
set fileOpened to true
set targetDocument to front slideshow
else
set fileOpened to false
end if
end tell
-- convert it, by GUI scripting
tell application "System Events"
tell process "Keynote"
set frontmost to true
click menu item "Export." of menu 1 of menu bar item "File" of menu bar 1
repeat until sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
click button "PDF" of tool bar 1
click radio button "Slides" of radio group 1
if value of checkbox "Print each stage of builds" = 1 then
click checkbox "Print each stage of builds"
end if
click button "Next."
end tell
repeat until button "Export" of sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
-- switch to desktop folder
keystroke "d" using command down
click button "Export"
end tell
delay 3 -- wait for the export to finish
end tell
end tell
tell application "Keynote"
-- close document if necessary
if fileOpened then close targetDocument saving no
end tell
set keynoteStarted to true
end if
end repeat
-- close any iWork apps that were not open to begin with
if pagesStarted and not pagesRunning then tell application "Pages" to quit
if numbersStarted and not numbersRunning then tell application "Numbers" to quit
if keynoteStarted and not keynoteRunning then tell application "Keynote" to quit
end open
============END SCRIPT===============