Search code examples
javascriptadobeadobe-illustrator

Adobe Illustrator Script to run every time I save


I'm wondering if there is a way have a jsx script execute every time Illustrator saves changes to a file.
The idea here is that the script will check to make sure the artboard is not too large to work with (for reasons not worth getting into here, the limit would ideally be 120 inches).

I think the script would look something like this...

function onSave () {
    var sizemessage = "Could not save, Artboard too large.";
    var sizethresh = "120";
    var length = artboardRect[2] - artboardRect[0];
    var height = artboardRect[3] - artboardRect[1];
    if (length >= height) {
        var size = length;
    } else {
        var size = height;
    }
    if (size > sizethresh) {
        beep ()
        alert(sizemessage)
        DONOTSAVECHANGES
    } else {
        SAVECHANGES
    }
}

I look forward to learning more.


Solution

  • try this code for event listner

    app.app.notifiers.add("save", File(/*insert the path of your jsx file here*/));