Last active
November 9, 2015 16:21
-
-
Save Gohla/03e94de6497ce6a02aa1 to your computer and use it in GitHub Desktop.
Exports OmniGraffle canvasses to .eps and .pdf files for use in latex. Call with ./export.applescript file.graffle generated/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/osascript | |
on replace_string(input, search, replacement) | |
set oldDelim to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to search | |
set textItems to every text item of input | |
set AppleScript's text item delimiters to replacement | |
set res to textItems as string | |
set AppleScript's text item delimiters to oldDelim | |
return res | |
end replace_string | |
on fullpath(location) | |
tell application "Finder" | |
set cwd to POSIX path of ((container of (path to me)) as alias) | |
end tell | |
return (POSIX path of (cwd & location)) | |
end fullpath | |
on run (argv) | |
set sourceFile to fullpath((get (item 1 of argv) as string)) | |
set targetDir to fullpath((get (item 2 of argv) as string)) | |
tell application "OmniGraffle" | |
open sourceFile | |
set area type of current export settings to all graphics | |
repeat with cvs in canvases of front document | |
# Deduce a filename based on the canvas name | |
set currentName to name of cvs as text | |
set cleanName to replace_string(currentName, " ", "_") of me | |
set canvas of front window to cvs | |
# Save as both EPS and PDF | |
set outputFile to targetDir & cleanName & ".eps" | |
save front document in POSIX file outputFile | |
set outputFile to targetDir & cleanName & ".pdf" | |
save front document in POSIX file outputFile | |
end repeat | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment