Answered
Saving a generated Illustrator document as a PDF to a file location using JavaScript
Hello, everyone;
I am writing a script using JavaScript to create a document from a template, then having a window open where the user enters information. The script then fills in text fields on the new document.
What I want it to do next is to save the file as a PDF to the same location using the file name that was generated. Here is the portion of code:
// The active document
var doc = app.activeDocument;
// The path of the original document
var docPath = "C:\Users\...\3 - Art Proof sent";
{
// Setup pdf save options
var opts = new PDFSaveOptions();
opts.pDFPreset = "Illustrator Default";
if (shortName.length > 0) {
doc.saveAs(File(docPath + "/" + shortName + ".pdf"), opts)
} else {
doc.saveAs(File(docPath + "/" + longName + ".pdf"), opts)
}
}
However, I always get the same error message:
Error 1200: an Illustrator error occurred: 112927-854 ('CONF')
Line: 1895
-> doc.saveAs(File(docPath + "/" + shortName + ".pdf"), opts)
This error seems particularly cryptic. Can anyone help me figure this out?
Thanks!
