Copy link to clipboard
Copied
Hi everyone,
I'm trying to create a document using the SDK. I found the AIDocumentListSuite, which seems to be just what I need, but when I try to create a document, it just returns the error "ENEW". The documentation just says that this means Illustrator failed to create a document, which doesn't tell me why it is not working.
This is my code:
AIDocumentListSuite* AIDocumentList;
ASErr error = message->d.basic->AcquireSuite(kAIDocumentListSuite, kAIDocumentListSuiteVersion, (const void**)&AIDocumentList);
if ((!error) && (AIDocument != nullptr))
{
ai::UnicodeString templ = ai::UnicodeString("A4");
AIDocumentHandle handle;
error = AIDocumentList->New(templ, NULL, kDialogOn, &handle);
if (!error)
{
error = AIDocumentList->Activate(handle, true);
if (error)
{
PopupBox(&message->d, nullptr, "Can't open created document: Open a document before connecting to MSD!");
}
else
{
// Do something with the document...
}
}
else
{
PopupBox(&message->d, nullptr, "Can't create document: Open a document before connecting to MSD!");
}
message->d.basic->ReleaseSuite(kAIDocumentListSuite, kAIDocumentListSuiteVersion);
AIDocument = nullptr;
}
Anybody has any idea on what the problem might be? Or where can I look?
Best regards,
Diogo
Also I tested your code and the issue is with the preset name. A4 is not the valid value for preset. I am quoting portion of the function description below.
Preset names are those that appear in the New Document dialog,
such as "Mobile", "Print", and so on.
Using the value Print worked for me. In your case a dialog will be shown because you have used kDialogOn, using which you can set the other params. In case you use kDialogNone in that case you can set the params using the second argument of t
...Copy link to clipboard
Copied
You could check the PlayActionEvent method from AIActionManagerSuite with kAINewDocumentAction. A sample of it is shown in the SnippetRunner sample(file SnpDocumentActionHelper, line no 586)
-Manan
Copy link to clipboard
Copied
Try setting the preset name to the empty string and supplying an AINewDocumentPreset struct. If Illustrator can't find "A4" it will fail. I've had situations where the presets you expect weren't available until some undisclosed point. If that works, there's your problem. I've generally found it's best to avoid using the preset name parameter in favour of the struct, so it's worth a shot.
Copy link to clipboard
Copied
Also I tested your code and the issue is with the preset name. A4 is not the valid value for preset. I am quoting portion of the function description below.
Preset names are those that appear in the New Document dialog,
such as "Mobile", "Print", and so on.
Using the value Print worked for me. In your case a dialog will be shown because you have used kDialogOn, using which you can set the other params. In case you use kDialogNone in that case you can set the params using the second argument of the New method.
-Manan
Copy link to clipboard
Copied
Thanks Manan! That was exactly the problem... I was seeing the "A4" as a template on my Illustrator, and I didn't remember to test some of the others templates, rookie mistake!
Changing it to "Print" solved it.
Thanks a lot!
Diogo