Document.close(SaveOptions.SAVECHANGES) now judges artboard loss by the
file the save writes. A PDF last saved with useArtboards: false is
refused, since it holds one page of the art's bounds. A native or .ai
file saved with separateArtboards is saved and closed whatever its range
names, since the range picks only the separate files; a version 7 .ai
file keeps the range check.
Document.saveAs, Document.exportFile, app.open and the save that
close(SaveOptions.SAVECHANGES) runs write each warning of their command
to the console after the method's name (for example "saveAs: SVG keeps 1
of the document's 2 artboards ...").
Script Check reports a file write for a saveAs or exportFile call on the
script's own object when the variable is assigned in a loop around the
call, since a later iteration may run the call on a document. Loop bodies
without braces follow if, else and line breaks, and a variable of the
same name that a function declares is kept apart.
A test shows that a waiting point change counts as unsaved for
Document.saved and close().
- saveAs picks the encoder from the requested name, so a link to a file of
another format writes the format the name asks for.
- fullName, path and close(SaveOptions.SAVECHANGES) resolve a relative saved
path against the working directory.
- close(SAVECHANGES) accepts an artboard range that covers every artboard and
keeps the document open when the save would drop artboards.
- app.open keeps the requested file name, rejects a file over 128 MiB before
reading it, applies the requested color space to plug-in imports, and
rejects PDF options for files that are not PDF content; null PDF options
keep their defaults.
- Explicit null options throw; assigning the current Document.saved value
runs no command; Document.path reflects as Folder or string.
- An implicit multi-file save names no refused path in its error.
- The script checker counts SAVECHANGES only on SaveOptions and keeps write
warnings for receivers that evaluated code can rebind.
- A save of several files whose file access refuses one of them returns
the refusal before any file goes to the writer, so a writer that does
not check the file access writes nothing.
- close(SaveOptions.SAVECHANGES) throws before writing, and leaves the
document open, when the document's last save named some of its
artboards, since saving with those options again could leave changes
out of the file.
- The script check no longer treats an object literal's saveAs or
exportFile as the script's own when a function body assigns the
variable without declaring it, or when the script assigns it as a
property of this (the global object in global code and in a function
called without a receiver).
- The close-with-SAVECHANGES format test reads the saved PDF and checks
that it holds the change made after the first save.
- docs/mcp.md limits the "none of them is written" sentence for SVG
linked images to refusals found before the first write, and documents
the new close refusal.
Brings in main through #9019's branch. The PDF presets now come from the shared pdf crate, so a bracketed preset name is looked up with the app's name and "Default" names its default preset.
Document.close(SaveOptions.SAVECHANGES) now saves in the format the document was last saved in, so a PDF saved to a file whose extension names another format stays a PDF. An artboardRange with no parts, such as ',' or ' , ', now throws, as a range used for the save does.
- Document.fullName is a File for the document's file, and Document.path a
Folder for its folder. A document without a file has a fullName of a
File for its name in Folder.current and a path of "". Both throw
`Script file access denied` with the document's name when the
automation read roots do not allow the file.
- Document.saved reads whether the document has unsaved changes. Setting
it runs the new command document.setSaved, which records the document
as saved or as changed without saving it and adds no undo step.
- Document.close(saveOptions) closes a document without unsaved changes
with any SaveOptions value. With unsaved changes,
SaveOptions.DONOTSAVECHANGES closes it without them, and
SaveOptions.SAVECHANGES saves them first with file.saveAs, in the
format the file's extension names and after the write-access check
saveAs makes, and throws for a document without a file (a converted
or recovered one included). SaveOptions.PROMPTTOSAVECHANGES, the
default, throws, since a script cannot show the prompt.
- The script checker reports SaveOptions.SAVECHANGES under filesWritten
wherever the script reads it.
- A pDFPreset in square brackets, such as [Smallest File Size], names
the built-in preset of the name inside them.
- artboardRange takes a whole number from 1 as well as a string; any
other number throws.
- With saveMultipleArtboards true, a .ai or EPS save also writes each
artboard of the range to a file of its own. Without it the range is
not used, but text that is not a range of artboard numbers throws.
Document page: https://ai-scripting.docsforadobe.dev/jsobjref/Document/
When the file access in force refuses one of the files a save writes, the save
gives that file to its writer for the error, as before, and then returns the
error even when the writer did not refuse it, so the other files are not
written.
- saveAs, exportFile and app.open throw "<Class> has no option <name>" for a
property their option class's help page does not list, instead of leaving it
out. An undefined property is still left out, and PDFFileOptions also takes
its read-only typename and parent.
- The script checker no longer reports a file write for saveAs or exportFile
called on a variable holding the script's own object literal that defines
that method, with `.` or in brackets. It reports it again once the method is
assigned or deleted, the object is indexed with a computed key, or another
name may hold the object.
- The read-only file test checks the open-document grant on its own, with no
folder scope that also covers the file.
A save or export to a file that a File object holds open for writing throws "Script file is open for writing", and a command the script runs does not write such a file besides the one named (an SVG's images), so the bytes the File writes at the end of the run do not replace the output. horizontalScale and verticalScale take 1 to 776.19, since a raster export writes at least 0.01 pixels per point.
The script checker reports a document's saveAs and exportFile as file writes, and the host name check lists the save, export and open names, option classes and enumerations.
Scripts save, export and open documents through Document.saveAs,
Document.exportFile and app.open, with IllustratorSaveOptions,
EPSSaveOptions, PDFSaveOptions, ExportOptionsPNG24, ExportOptionsJPEG,
ExportOptionsSVG and a PDFFileOptions record, the ExportType and related
enumerations, and app.userInteractionLevel. Each method runs file.saveAs,
document.export or document.open inside the run's transaction.
- A File argument reaches the host as its path only when the File class
made it: the path is held in an internal slot that scripts cannot set,
and a plain object that imitates a File is refused.
- Each path is checked as a File opened for reading or writing would be,
before the command runs, and the command's own reads and writes are then
held to the script's grants, leaving out the open documents' files.
A read-only file is not written over.
- Options a command maps are applied; a listed option that is not mapped
is accepted only at its documented default, and any other value, a bad
type or an out-of-range number throws before anything is written.
Without options, saveAs to a .ai, .eps or .pdf path and exportFile as
PNG24, JPEG or SVG use the defaults a new options object holds. With
pDFPreset named, a PDFSaveOptions option still at its default keeps the
preset's value. A raster export at 100% has one pixel per point.
- An export or save that writes several files, such as an SVG that writes
its embedded images beside it or an EPS with a file per artboard, checks
every path before writing the first.
Docs: docs/mcp.md, docs/target-app-parity.md.