Skip to content

Instantly share code, notes, and snippets.

@arthurlevy
Forked from archgrove/OGExportAllForLaTeX.scpt
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save arthurlevy/22829210696178bb93fd to your computer and use it in GitHub Desktop.

Select an option

Save arthurlevy/22829210696178bb93fd to your computer and use it in GitHub Desktop.
# Replace "search" with "replacement" in "input" (all text)
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
tell application "OmniGraffle Professional 5"
set outputPath to (choose folder) as text
# Save the original canvas for restoration
set originalCanvas to canvas of front window
# Confgure 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
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 outputPath & cleanName & ".eps"
save front document in outputFile
set outputFile to outputPath & cleanName & ".pdf"
save front document in outputFile
end repeat
set canvas of front window to originalCanvas
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment