Skip to main content
Participant
June 29, 2016
Answered

I need a script that would provide leading to different text frames.

  • June 29, 2016
  • 1 reply
  • 347 views

Hello,

I need a script that would change every text frame leading. Is it possible to make one?

This topic has been closed for replies.
Correct answer Silly-V

This this sample script which works on a selection of text frames:

#target illustrator

function test(){

  var doc = app.activeDocument;

  var s = doc.selection;

  if(s == null && s.length == 0){

    return;

  }

  for(var i = 0; i < s.length;  i++){

    if(s.typename != "TextFrame"){

      continue;

    }

    s.textRange.characterAttributes.autoLeading = false;

    s.textRange.characterAttributes.leading = 22;

  };

};

test();

1 reply

Silly-V
Silly-VCorrect answer
Legend
June 29, 2016

This this sample script which works on a selection of text frames:

#target illustrator

function test(){

  var doc = app.activeDocument;

  var s = doc.selection;

  if(s == null && s.length == 0){

    return;

  }

  for(var i = 0; i < s.length;  i++){

    if(s.typename != "TextFrame"){

      continue;

    }

    s.textRange.characterAttributes.autoLeading = false;

    s.textRange.characterAttributes.leading = 22;

  };

};

test();

Participant
June 30, 2016

Hi Silly-V,

Script works like a charm. However, how should I make it, that it would automatically take all or one by one text frames and give the same leading?

Kipras

Silly-V
Legend
June 30, 2016

change "var s = doc.selection;" to

var s = doc.textFrames;