Canvas Properties

A OmniGraffle canvas, like most scriptable objects, has properties that define its characteristics and abilities. In the previous section, the canvas properties of id and size were used in script examples to create and move canvases within an OmniGraffle document. This section further examines the canvas properties of name, size, and autosize, and how they are used in common scripting scenarios.

Here’s the complete list of canvas properties:

Using the background property to change the fill color of the current canvas:

graphic =[0].selection.canvas.background graphic.fillColor = Color.gray

CanvasSizingMode Properties

The CanvasSizingMode properties are the value for the canvasSizingMode property (note lowercase c) of the Canvas class:


In an OmniGraffle document, the size (width/height) of canvases may vary. They all may have the same dimensions or not, it’s up to you.

And for those situations where you want the canvas to tightly wrap the graphics it contains, there are autosize options to have one or more of the dimension directions automatically size itself to snug the outermost graphic in that direction.

NOTE: the value of the canvas canvasSizingMode property must be set to Fit for these properties to be effective.


In the illustration above, autosizing is active for the left and downward directions. In terms of scripting, there are four canvas autosizing properties: autosizesDown, autosizesLeft, autosizesRight, and autosizesUp. Each property has a boolean value of either true or false indicating whether the autosize property is active or not.

In the script example below, four script statements are used to set the values of the four autosizing properties:

cnvs =[0].selection.canvas cnvs.canvasSizingMode = CanvasSizingMode.Fit cnvs.autosizesDown = true cnvs.autosizesLeft = true cnvs.autosizesRight = false cnvs.autosizesUp = false

However, if you want to set all four autosizing properties to the same boolean value, you can use the following JavaScript construct to do it with one script statement:

cnvs =[0].selection.canvas cnvs.autosizesUp = cnvs.autosizesDown = cnvs.autosizesLeft = cnvs.autosizesRight = false

IMPORTANT: if an auto-sizing property has been enabled, and then disabled, the size of the canvas prior to applying auto-sizing, will not be automatically restored.


Setting the dimensions of a canvas can be very useful, especially if the canvas is to be printed or exported for use with specific sized displays.

Here is a script example of how to size a canvas to match the current settings in the Page Setup dialog (macOS).

cnvs =[0].selection.canvas cnvs.canvasSizingMode = CanvasSizingMode.Fixed cnvs.size = new Size(cnvs.pageSize.width, cnvs.pageSize.height)
page setup sheet

And a version for sizing every canvas:

canvases.forEach(function(cnvs){ cnvs.canvasSizingMode = CanvasSizingMode.Fixed cnvs.size = new Size(cnvs.pageSize.width, cnvs.pageSize.height) })

And for those times when you’re designing interfaces for specific devices, having the ability to quickly create templates is very useful:

[a, b] = [2048, 1536].slice() addCanvas().size = new Size(a, b) addCanvas().size = new Size(b, a)


In complex documents, canvas names can provide clarity, navigation, and the structure for exporting content. The value of the name property of a canvas is a text string that can be both read and changed.

For example, the following script both gets the name of the current canvas, and changes its name by appending the word “DRAFT” to the end of the name.

var currentCanvas =[0].selection.canvas = + ' DRAFT'

To get a list of the names of the canvases in a document, use the JavaScript map() method:{return})

And to check if a canvas with a specific name is in the document, use the JavaScript includes() method, which has a result that is either true or false:

canvasNames ={return}) canvasNames.includes('name to compare')

And here is a script showing how to name the current canvas a unique name:

canvasName = "Name for Canvas" currentCanvas =[0].selection.canvas canvasNames ={return}) if (canvasNames.includes(canvasName)){ alertMsg = "There is already a canvas named: " + canvasName new Alert('Naming Error',alertMsg).show(function(result){}) } else { = canvasName }

And a script that creates a new canvas and names it an incrementation of a specific name:

cnvs = addCanvas() baseName = "My Canvas Name" versName = "My Canvas Name" cnvsNames ={return}) counter = 0 while (cnvsNames.includes(versName)){ counter = counter + 1 versName = baseName + "-v" + String(counter) } = versName

If you re-order the canvases in a document but want the new order to be reflected in the canvas names, here the script:

cvss = canvases.reverse() for(i = 0; i < cvss.length; i++){ nmeNum = i + 1 canvases[i].name = 'Canvas ' + nmeNum }

Here is a script function for returning a reference to a canvas specified by its name:

function getCanvasNamed(canvasName){ for (let cnvs of canvases){ if ( === 0){return cnvs} } errorString = "There is no canvas named: " + canvasName new Alert('ERROR', errorString).show(function(result){}) throw new Error(errorString) } getNamedCanvas('iPad Horizontal')

And here is a script that creates and names a canvas for each month of the year:

function addCanvasForEveryMonth(){ locale = "en-us" curYearStr = String(new Date().getFullYear()) mths = new Array() for (i = 1; i < 12; i++) { var date = new Date(i + "/1/" + curYearStr), month = date.toLocaleString(locale, { month: "long" }) mths.push(month) } sze =[0].selection.canvas.size canvasNames ={ return }) mths.forEach(function(mth){ if(canvasNames.indexOf(mth) === -1){ cnvs = addCanvas() = mth cnvs.size = sze } }) } addCanvasForEveryMonth()

CanvasSizingMode Properties

The VerticalAlignment properties are the value for the columnAlignment property of the Canvas class:


HorizontalAlignment Properties

The HorizontalAlignment properties are the value for the rowAlignment property of the Canvas class:



An outline node is one element of a hierarchical organization of the canvas’s graphics. Each node represents a single shape, with the lines between shapes determining parent-child relationships. The outline structure is visualized in the Mac applications ‘Outline’ sidebar tab.


This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.