Copy link to clipboard
Copied
Hello,
I would like to automate(script) a workflow which saves my current file as pdf.
as it is, here are my current mouse clicks:
1-Go to file: Save as
2-Select, if not selected, pdf format.
3-Check to save in the same location as the original folder
4-Select the pdf options which are a pdfx-1a hybrid.
Done.
I would love to simplify those steps with one click.
I tried it with actions but it keeps saving new files into the original folder that originated the action.
Can the above be done withe Javascript?
Thanks,
Freddie
Try below code. It might works...
var pdfFile = new File(app.activeDocument.fullName.toString().replace(".ai",".pdf"));
var saveOpts = new PDFSaveOptions(); //You can set PDF SaveOptions like below properties...
saveOpts.PDFXStandard = 2; //X1a 2001
app.activeDocument.saveAs (pdfFile, saveOpts);
Copy link to clipboard
Copied
You can reference below snipet:
var pdfFile = new File(app.activeDocument.fsName.replace(".ai",".pdf"));
var saveOpts = new PDFSaveOptions(); //You can set PDF SaveOptions like below properties...
saveOpts.PDFXStandard = 2; //X1a 2001
app.activeDocument.saveAs (pdfFile, saveOpts);
In this case, We can use saveAs method under the document object.
Copy link to clipboard
Copied
I tried running it without editing.
I opened an ai file and ran the script.
I know I need to edit it but my javascript skills are nascent.
I get this:
Error 21: Undefined is not an object.
Line: 1
-> var pdfFile=new
File(app.activeDocument.fsName.replace(".ai",".pdf"));
Can you run with an actual file and post the results?
I'm wondering if it is a syntax issue.
Copy link to clipboard
Copied
Try below code. It might works...
var pdfFile = new File(app.activeDocument.fullName.toString().replace(".ai",".pdf"));
var saveOpts = new PDFSaveOptions(); //You can set PDF SaveOptions like below properties...
saveOpts.PDFXStandard = 2; //X1a 2001
app.activeDocument.saveAs (pdfFile, saveOpts);
Copy link to clipboard
Copied
Thank you!
I owe you a beer! at least...
Awesome. Four lines of code that will save me countless clicks during the day. Thanks Again.