Hello,
I am not a huge coder, but have pieced together a script to save out a canvas as a series of png’s.
However it is not working perfecty and grabs only a small elements on some pages and the whole canvas on others.
What I want to do is to get a specific region of each canvas as you can in the export as Dialouge in file/export as. i.e.
Can anyone help me edit this script to do that?
This is my current script
----------start ----------
-Choose the output folder. Script ends if cancelled
set strOutputDirectory to choose folder
–Get the name of the current file
tell application “OmniGraffle”
set objOmniGraffleFile to front document
set strOmniGraffleFileName to name of objOmniGraffleFile as string
end tell
–Drop the file extension
set strOmniGraffleFileNameNoExtension to remove_extension(strOmniGraffleFileName)
–Export each canvas
tell application “OmniGraffle”
–Initialise
set objOmniGraffleFile to front document
set canvas of front window to canvas 1 of objOmniGraffleFile
set intCanvasCount to count of canvases of objOmniGraffleFile
--Iterate through each canvas and export it to the specified folder
--File name will be the file name of the file with a hyphen and then the name of the canvas
--Files saved in PNG format
repeat with intCurrentCanvasID from 1 to intCanvasCount
set canvas of front window to canvas intCurrentCanvasID of objOmniGraffleFile
set currentCanvas to canvas of front window
set strOutputFilePath to strOutputDirectory & strOmniGraffleFileNameNoExtension & " - " & name of currentCanvas & ".png" as string
save objOmniGraffleFile as "png" in (strOutputFilePath)
end repeat
end tell
–Display a final message about the exports
display dialog "Exported " & intCanvasCount & " files to
" & strOutputDirectory with title “Export Complete”
– Remove file extension (from http://www.macosxautomation.com/applescript/sbrt/)
on remove_extension(this_name)
if this_name contains “.” then
set this_name to ¬
(the reverse of every character of this_name) as string
set x to the offset of “.” in this_name
set this_name to (text (x + 1) thru -1 of this_name)
set this_name to (the reverse of every character of this_name) as string
end if
return this_name
end remove_extension
----------End ------------
Thanks for any advice