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

Need help Scripting

Community Beginner ,
May 26, 2016 May 26, 2016

Copy link to clipboard

Copied

   I am a beginner at scripting, coding, and web design. I have been having questions regarding scripting.

I need help developing an Adobe Script that will 1)Automatically open a PDF file I have (created in Illustrator CC 2015)

                                                                              2) Automatically change the name of two swatches,  to new names I have

                                                                              3) Save with same file name plus "_Z.PDF" at the end

                                                                               4) Then close the file.

TOPICS
Scripting

Views

399

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
Adobe
Enthusiast ,
May 27, 2016 May 27, 2016

Copy link to clipboard

Copied

So you mean you've saved all your pdf file with "Preserve Illustrator Editing Capabilities" option checked on? You can start from here.

// 1)

var f = new File('path/to/filename.pdf');

var doc = app.open(f);

// 2)

doc.swatches.getByName('swatch_1').name = 'new_swatch_1';

doc.swatches.getByName('swatch_2').name = 'new_swatch_2';

// 3)

doc.saveAs(new File(f.fsName.replace(/\.pdf$/, '_Z.pdf')), new PDFSaveOptions());

// 4)

doc.close();

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 ,
May 27, 2016 May 27, 2016

Copy link to clipboard

Copied

Thank you very much for your time and help. I tried running the script this way below but it says

there is still an error in the part :  var doc = app.open(f);

What should I do about this? I have it underlined below too in bold italics.

function test()

{

    // 1) 

    var thePath = "~/Desktop/";

    var theFile = "test_swatch_change.pdf";

    var f = new File(thePath + theFile); 

    var newFileName = theFile.replace(/\.pdf$/, "_Z.pdf");

   var doc = app.open(f);

    // 2) 

    doc.swatches.getByName('Kiss Cut').name = ('CutContourKiss-cut'); 

    doc.swatches.getByName('Through Cut').name = ('CutContourThru-cut'); 

    // 3) 

    var saveFile = new File(thePath + newFileName);

    var saveOpts = new PDFSaveOptions();

   

    doc.saveAs(saveFile, saveOpts); 

    // 4) 

    doc.close(); 

}

test();

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
Enthusiast ,
May 28, 2016 May 28, 2016

Copy link to clipboard

Copied

Just works fine here.

try { var doc = app.open(f) } catch (e) { alert(e) }

what's the error info?

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 ,
May 28, 2016 May 28, 2016

Copy link to clipboard

Copied

It says its not a function. I think its app.open that they are referring too.

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
Enthusiast ,
May 28, 2016 May 28, 2016

Copy link to clipboard

Copied

Oh no, did you run it from ESTK and had not set target to illustrator?

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 ,
May 29, 2016 May 29, 2016

Copy link to clipboard

Copied

LATEST

yes, it wasnt going through

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