How to check a large canvas

AiScripts
2 min readAug 25, 2022

--

In Illustrator, the document canvas was limited to 227 × 227 inches. Since version 24.2 (СС 2020), you can create a document in large canvas mode, where the working area is 100 times larger (2270 × 2270 inches).

Illustrator will automatically create an artboard on a large canvas

The large canvas mode in the Illustrator interface scales all sizes by a factor of 10. Two years later, the scripts have no methods for checking the canvas mode and still count all sizes at what they think is a “real” 1:10 scale. What the user sees in the app interface and gets in the script does not match.

Dimensions in 1:10 scale

Simple solution

The app.activeDocument.scaleFactor attribute, which returns the scale factor, has been added to global document variables since CC 2020: 1 — normal canvas, 10 — large. We’ll use this factor to calculate the size of artboards, objects.

Checking the canvas mode and recalc the visible dimensions
var coeff = app.activeDocument.scaleFactor ? app.activeDocument.scaleFactor : 1;
var width = selection[0].width;
width *= coeff;

The ternary operator is needed to make the script compatible with Illustrator CC 2019 and below, where there was no large canvas mode. scaleFactor will return undefined and assign 1 to the coefficient.

More info

New versions of Adobe Illustrator write a comment into the document structure containing the canvas scale value %AI24_LargeCanvasScale: 1 — normal canvas, 10 — large canvas. If there were no global variable, we could find the scaling factor this way. Notes:

  • if the document was created in an earlier version, it will not have %AI24_LargeCanvasScale
  • the new document must be saved before running the script
function isLargeCnvs(doc) {
var $file = File(doc.fullName),
str = '';
$file.open('r');
while (!$file.eof) {
str = $file.readln();
if (/^%AI24_LargeCanvasScale/.test(str)) {
var ratio = (/\d+$/).exec(str)[0];
return ratio == '10';
}
}
$file.close();
return false;
}
var isLarge = isLargeCnvs(activeDocument);
var width = selection[0].width;
width *= isLarge ? 10 : 1;

As you can see, the alternative solution is more complicated and because of the need to save the document is not universal.

--

--

AiScripts
AiScripts

Written by AiScripts

Sergey Osokin. Product Illustrator, Icon Designer, Script Developer (Ai, Ps). Writing about bugs and tricks in Adobe Illustrator scripts