Copy link to clipboard
Copied
i try this method:
var newDoc=app.documents.addDocument("A4", app.getPresetSettings("A4"));
But it occur error:
an Illustrator error occurred: 1346458189 ('PARM')
How can add a document size A4?
1 Correct answer
you can't just add your own arguments. Look at the documentation to find out what kind of arguments you need to pass to the addDocument function. The function is expecting Color Mode and a document Preset
// create A4 size document
var docPreset = new DocumentPreset;
docPreset.width = 595.28;
docPreset.height = 841.89;
docPreset.units = RulerUnits.Millimeters;
docPreset.colorMode = DocumentColorSpace.RGB;
var idoc = app.documents.addDocument(DocumentColorSpace.RGB, docPreset);
Explore related tutorials & articles
Copy link to clipboard
Copied
you can't just add your own arguments. Look at the documentation to find out what kind of arguments you need to pass to the addDocument function. The function is expecting Color Mode and a document Preset
// create A4 size document
var docPreset = new DocumentPreset;
docPreset.width = 595.28;
docPreset.height = 841.89;
docPreset.units = RulerUnits.Millimeters;
docPreset.colorMode = DocumentColorSpace.RGB;
var idoc = app.documents.addDocument(DocumentColorSpace.RGB, docPreset);
Copy link to clipboard
Copied
Hello,
it is possible to define font size at docPreset?
Copy link to clipboard
Copied
No. Font size is not a DocumentPreset property.
Copy link to clipboard
Copied
I recently noticed the documents.addDocument() function in the documentation is wrong. It's a miracle that it works as written above.
the addDocuments() first argument should be a document preset, not ColorSpace. ColorSpace is the first argument of the documents.add() function
so, technically, it is possible to add a default font to new documents created as long as your first create a New Document Profile.
then in your script
var docPreset = new DocumentPreset;
// ....add preset properties if you want to override the deafult "profile" document
var docProfile = 'myProfile'; // or default "Print" or "Web"
var idoc = app.documents.addDocument(docProfile, docPreset, false);
it doesn't work perfectly as it seems to always create CYMK documents, but at least that can be overwritten with docPresets properties.
Copy link to clipboard
Copied
Thank you,
I will go with your suggestion
Copy link to clipboard
Copied
Hi @CarlosCanto
The documentation states that addDocument's arguments are
addDocument(startupPreset, presetSettings)
with the second, presetSettings, being a DocumentPreset object.
The first, the startupPreset, is said to be a string. Where does one get this string from and what is it related to?
Thanks in advance.
Copy link to clipboard
Copied
Hi @femkeblanco, the documentation is wrong. The first argument should be a document preset string. Valid strings are the names of the document profiles saved in your system, default or created by you. These are the same document profiles you see when you create a New Document by hand.
this is the correct info
Documents.addDocument (startupPreset: string , presetSettings: DocumentPreset , showOptionsDialog: Boolean 😞 Document Adobe Illustrator 25 Type Library Create a new document from a preset. startupPreset: Data Type: string The name of a startup document preset. presetSettings (optional): Data Type: DocumentPreset Custom settings to apply to the preset. showOptionsDialog (optional): Data Type: Boolean If false, do not show Options dialog.
Copy link to clipboard
Copied
Thank you @CarlosCanto . That's very helpful.

