Skip to main content
Inspiring
October 8, 2021
Answered

Saving a generated Illustrator document as a PDF to a file location using JavaScript

  • October 8, 2021
  • 1 reply
  • 340 views

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!
This topic has been closed for replies.
Correct answer femkeblanco

What about changing the path to "/c/Users/.../3 - Art Proof sent"

 

 

1 reply

femkeblanco
femkeblancoCorrect answer
Legend
October 8, 2021

What about changing the path to "/c/Users/.../3 - Art Proof sent"