How to check a large canvas

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

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.

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
AiScripts

Sergey Osokin. I’m a illustrator & Script Developer (Ai, Ps). Writing about bugs and tricks.