View Single Post
Okay this code now works (it is cleaned up a bit as well)

It saves a PDF version of the current canvas in the same directory as the original .graffle file. It takes the file name from the name of the canvas since you might have multiple canvases.

tell application "OmniGraffle"
	set thedocument to front document
	set thePath to the path of the thedocument
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "/"
	set theDirectory to (text items 1 through -2 of thePath) as text
	set AppleScript's text item delimiters to ASTID
	# Save the original canvas for restoration
	set originalCanvas to canvas of front window
	set canvasName to name of originalCanvas as text
	# Configure the output type to all graphics
	# Which will be interpreted as "current canvas" in PDF and EPS files
	set area type of current export settings to all graphics
	# Save as PDF
	set pdfFile to theDirectory & "/" & canvasName & ".pdf"
	#display dialog pdfFile
	save front document in POSIX file pdfFile
end tell