Skip to main content
Known Participant
January 21, 2022
Answered

Script for saving current document into .eps and .pdf format in different names

  • January 21, 2022
  • 1 reply
  • 725 views

Example:

I have opend document in illustrator namely  "Untitled_1.ai". I want to save this file as "Untitled_1.eps" and "Untitled_1_FORPRINT.pdf". 

 

I am facing the issue with the below script, "_FORPRINT" was not coming along with the filename while it is saved as PDF.

 

var saveOpts = new EPSSaveOptions();
var saveName = new File("~/Documents/Project/Output Files/" + "/" + app.activeDocument.name);
document.saveAs(saveName, saveOpts);

var saveName = new File("~/Documents/Project/Output Files/" + "/" + app.activeDocument.name + "_FORPRINT");
var saveOpts = new PDFSaveOptions();
saveOpts.preserveEditability = true;
PDFSaveOptions.viewAfterSaving = false;
document.saveAs(saveName, saveOpts);
document.saveAs(saveName, saveOpts);

This topic has been closed for replies.
Correct answer Charu Rajput

It may be because, pdf is created from the eps document(this is active now) and eps document name is Untitled-11.eps and app.actievDocument.name return name with extension. So extract name first as

 

var _name = app.activeDocument.name.replace('.ai');

 

and use _name where you have used app.activeDocument.name while saving in eps or pdf format.

1 reply

Silly-V
Legend
January 21, 2022

Change it to something like this when doing the files.

Change:
new File("~/Documents/Project/Output Files/" + "/" + app.activeDocument.name + "_FORPRINT");

 

To:
new File("~/Documents/Project/Output Files/" + app.activeDocument.name + "_FORPRINT.pdf");

Surya24Author
Known Participant
January 21, 2022

Thank you so much for your response, but i am getting the extra word like ".eps" in saved file name. Refer the below screenshot.

 

 

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
January 21, 2022

It may be because, pdf is created from the eps document(this is active now) and eps document name is Untitled-11.eps and app.actievDocument.name return name with extension. So extract name first as

 

var _name = app.activeDocument.name.replace('.ai');

 

and use _name where you have used app.activeDocument.name while saving in eps or pdf format.

Best regards