The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Applescript to save and export as pdf Thread Tools Search this Thread Display Modes

As I'm currently writing a presentation, I'm spending a lot of time doing or tweaking OmniGraffle files and exporting them as pdf. To streamline the process, I wrote a simple AppleScript that I bound to a trigger in Quicksilver. Here is the script:

-- files are assumed to be in some dir xxx/foo/file.graffle
-- (typically xxx/graffle/file.graffle)
-- the pdf file will be saved under xxx/pdf/file.pdf
tell application "OmniGraffle Professional"
	set docName to name of first document
	set docFileUnix to path of first document
end tell
if docName = "Untitled" then
	display dialog "Save file first!" buttons "Cancel" default button "Cancel"
	set pdfName to (do shell script "echo " & docName & "| sed -e 's/\\(.*\\)\\.graffle/\\1/'") & ".pdf"
	set docFile to POSIX file docFileUnix
	tell application "Finder"
		set rootPath to (parent of (parent of file docFile)) as text
	end tell
	set pdfFile to rootPath & "pdf:" & pdfName
	tell application "OmniGraffle Professional"
		save first document in pdfFile
		save first document in docFile
	end tell
end if
The only small trouble with this script is that after running it, the document has forgotten where it's saved. So the process I follow is:
- open the document
- modify it and use the script
- close the document

The first step makes sure that the document knows its save location.

If someone knows why is this so, or has improvements to this script, I'd love to hear about it.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
How I save a perspective with AppleScript? kroger OmniFocus Extras 2 2012-03-23 10:56 PM
Applescript to Save Clipboard to Clippings? jamespro OmniOutliner 3 for Mac 0 2011-03-23 11:11 AM
AppleScript save as PDF - how can I get the whole page? jerremy OmniGraffle General 7 2009-03-14 03:17 PM
Applescript save? wblj OmniOutliner 3 for Mac 3 2008-07-02 11:30 AM
Applescript hook for save as web archive jsg OmniWeb Feature Requests 0 2006-11-15 11:06 AM

All times are GMT -8. The time now is 01:30 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.