Hi, when I create a new document via jsx script, it comes up as unnamed-1 or such.
I could of course pop up a save dialog suggesting a folder path and name, and I couuld perhaps add a save button to the script's UI if there is no better solution
Now, for a process where the lifetime of documents will usually be short, I would like to just preset a name and leave it to the user to actually save the file
A document's name is read-only. The only way to change a document's name is through the file path when saving.
create new document with specific name:
var doc = app.activeDocument; var namedoc=prompt("type a document name") var presets = app.startupPresetsList; var preset = presets; var docPreset = new DocumentPreset(); docPreset.title = namedoc; docPreset.rasterResolution = DocumentRasterResolution.HighResolution docPreset.colorMode = DocumentColorSpace.CMYK; docPreset.units = RulerUnits.Inches; var doc = app.documents.addDocument(preset, docPreset, false); doc.rulerOrigin = [0,0];
The name can be added this way (but beware: the document itself is not yet saved this way)
var newDocPresets = new DocumentPreset; newDocPresets.title = "Test-Document"; var newDoc = app.documents.addDocument( "Basic RGB", newDocPresets );
Hi, many thanks, I will give it a try, but I will have to look up details, because I need RGB colorspace as well as a dimension determined by the script
My snippet does what you asked. I am happy about that.
The snippet from @GerssonDelgado is a bit more detailed and offers a few additional options. That's why I'm also marking his answer as correct. I hope that's okay with you.
For specific dimensions, the following properties can be used (in my snippet):
newDocPresets.width = 200; // in points newDocPresets.height = 400; // in points