Skip to main content
Known Participant
November 18, 2022
Answered

Save to PDF and AI (up to CS6)

  • November 18, 2022
  • 1 reply
  • 1291 views

Is there any script that will allow me to save/export a pdf and ai project (in version for cs6) "in one click"? I have already tried various ready-made solutions that I found on the Internet, I even tried to create my own, but none of them met my assumptions

 

I mean specifically a script where it gives a name (adds a number at the beginning of the file name) and saves two files (pdf and AI in CS6) in the folder where the file was opened

 

Thank you for your help sorry for my english - i don't know this language well

This topic has been closed for replies.
Correct answer femkeblanco

One question.
I want what will be added to the file name to be at the end, you need to significantly rewrite the code? What I added, unfortunately, does not work - it does not add anything at the end of the name

var name1 = prompt("NR NG:", "");
var version1 = prompt("wersja:", "");
var file1 = new File(app.activeDocument.path + "/" + name1 + app.activeDocument.name + version1);

 


app.activeDocument.name will have an extension (.ai or .pdf) that needs to be removed before a string can be added to it.

var name1 = prompt("NR NG:", "");
var version1 = prompt("wersja:", "");
var file1 = new File(app.activeDocument.path + "/" + name1 + app.activeDocument.name.replace(/\.[^\.]+$/, "") + version1);
var AI = new IllustratorSaveOptions();
AI.compatibility = Compatibility.ILLUSTRATOR16;
var PDF = new PDFSaveOptions();
app.activeDocument.saveAs(file1, AI);
app.activeDocument.saveAs(file1, PDF);

 

1 reply

femkeblanco
Legend
November 18, 2022

You can change the number in line 1 and the directory path in line 2. 

var no = 1;
var directory = "~/Desktop/";
var file1 = new File(directory + no + app.activeDocument.name);
var AI = new IllustratorSaveOptions();
AI.compatibility = Compatibility.ILLUSTRATOR16;
var PDF = new PDFSaveOptions();
app.activeDocument.saveAs(file1, AI);
app.activeDocument.saveAs(file1, PDF);

 

Known Participant
November 21, 2022

Thank you very much for your help!
Is there a way to save the file to the same location it was opened from?