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

Scripting a repetitive save as command?

Community Beginner ,
Jul 29, 2017 Jul 29, 2017

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
1.0K
Translate
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); 

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

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.

Translate
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

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.

Translate
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

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

Translate
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
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.

Translate
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