The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Applescript to save and export as pdf (http://forums.omnigroup.com/showthread.php?t=1377)

brab 2006-08-10 12:20 AM

Applescript to save and export as pdf
 
Hello,

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"
else
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 07:46 AM.

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