Skip to main content
Participating Frequently
June 13, 2014
Answered

Editing the leading on a created textFrame

  • June 13, 2014
  • 1 reply
  • 1122 views

Hi,

I have no idea why the following code will not work.

The text displays in the correct place with the correct contents but i cannot get the leading to change.

var textInfo = app.activeDocument.textFrames.add();

textInfo.name = "textInfo";

textInfo.position = [30,-30];

textInfo.contents = "A";

textInfo.autoLeading = false;

for(var i = 0; i<app.activeDocument.textFrames["textInfo"].textRange.characters.length; i++){

    app.activeDocument.textFrames["textInfo"].textRange.characters.characterAttributes.leading = 18;

    redraw();

    $.writeln(app.activeDocument.textFrames["textInfo"].characters.characterAttributes.leading);

    }


I have also tried textInfo.leading = 18; with no luck.


The write line function at the end is reading the correct leading but the line above is not editing it.


Adobe illustrator CS6, Mac OS 10.6, Javascript/extendscript

Also, not too sure what auto leading does so have tried both with and without.


Thanks,

Tom

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi t1d2c3,

IMHO you don't need a loop trough all characters.

Please try this instead.

var textInfo = app.activeDocument.textFrames.add();

textInfo.name = "textInfo";

textInfo.position = [30,-30];

textInfo.textRange.characterAttributes.autoLeading = false;

textInfo.textRange.characterAttributes.leading = 40;

textInfo.contents = "Abcdef";

Have fun

1 reply

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
June 13, 2014

Hi t1d2c3,

IMHO you don't need a loop trough all characters.

Please try this instead.

var textInfo = app.activeDocument.textFrames.add();

textInfo.name = "textInfo";

textInfo.position = [30,-30];

textInfo.textRange.characterAttributes.autoLeading = false;

textInfo.textRange.characterAttributes.leading = 40;

textInfo.contents = "Abcdef";

Have fun

t1d2c3Author
Participating Frequently
June 16, 2014

Worked perfectly, thanks