Search code examples
javascriptadobe-illustratorextendscript

Check if the current document is saved


I'm just wondering if any javascript can check/detect if the current document is already saved or updated.

I've search on the web but I got nothing.


Edit: If the active document that is open in Illustrator has unsaved changes I want to have an alert that indicates the document has not been saved yet.


Solution

  • On page 38 of the titled: Adobe Illustrator CC 2017 Scripting Reference: JavaScript it states that the Document object has a saved property.

    It is described as follows:

    Property : saved
    Value Type : boolean
    Description : If true, the document has not been changed since the last time it was saved.

    Therefore you can do the following:

    if (!app.activeDocument.saved) {
      alert("The document has changed since the last time it was saved", 'Unsaved Changes', true)
    }
    

    The example code (above) alerts the user if the saved property is false.