• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scripting a repetitive save as command?

Community Beginner ,
Jul 29, 2017 Jul 29, 2017

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

TOPICS
Scripting

Views

796

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 30, 2017 Jul 30, 2017

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); 

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 30, 2017 Jul 30, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2017 Jul 30, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2017 Jul 30, 2017

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); 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2017 Jul 30, 2017

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines