I am trying to save a file in Illustrator using Javascript, but I get an error all the time.
Here is what works, but not what I want:
var dest = "~/testme.pdf";
saveFileToPDF(dest);
function saveFileToPDF (dest) {
var doc = app.activeDocument;
if ( app.documents.length > 0 ) {
var saveName = new File ( dest );
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
alert(saveName);
doc.saveAs( saveName, saveOpts );
}
}
var "dest" saves the file in the root of my Mac user account. I just want to save the file relative to the original document in a subfolder, so I tried this:
var dest = "exports/testme.pdf";
A dialog will appear with ".pdf", highlighted, waiting for input inside the "export" folder that I have already created. I can print something and it will save, but ignore the testme.pdf file name specified in the code. I can type “cheese” over the selected “.pdf”, it knows what I want and it will save “cheese.pdf” in the “export” folder.
I also tried them with no luck:
var dest = "exports/testme";
var dest = "/exports/testme.pdf";
var dest = "testme.pdf";
etc. etc.
What am I missing?