The Omni Group Forums

The Omni Group Forums (
-   OmniGraffle General (
-   -   Applescript to save and export as pdf (

brab 2006-08-10 01:20 AM

Applescript to save and export as pdf

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:

[CODE]-- 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[/CODE]

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.

All times are GMT -8. The time now is 02:48 AM.

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