Skip to main content
Known Participant
July 31, 2017
Answered

Change leading value

  • July 31, 2017
  • 2 replies
  • 1787 views

Hi,

I have some paragraphs with overrides applied manually across the document.

I want to apply the leading that are in each respective paragraph styles without do the clearOverrides method because I have italic or colored words with no char style applied that I don't want to "clear".

Thank you in advance.

This topic has been closed for replies.
Correct answer Loic.Aigon

You can use everyItem() in a collection purpose but you would still need to introspect every single paragraph as they may have different leading values.

var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

var n = myParas.length;

while ( n-- ) {

myParas.leading = myParas.appliedParagraphStyle.leading;

}

2 replies

Loic.Aigon
Legend
August 3, 2017

Given that app.selection[0] is your group you need to introspect allPageItems property which is an array. If the nth item is of kind TextFrame you can then apply paragraphs changes.

RibnogAuthor
Known Participant
August 3, 2017

I see that's the way, but I don't know how to put this theory in the code. I'm a novice in javascript with indesign.

Can you help with the code? Sorry to bother you again

Loic.Aigon
Legend
July 31, 2017

myPara.leading = myPara.appliedParagraphStyle.leading;

RibnogAuthor
Known Participant
July 31, 2017

And the var myPara would be? I tried app.activeDocument.stories.everyItem but not work.

Loic.Aigon
Loic.AigonCorrect answer
Legend
July 31, 2017

You can use everyItem() in a collection purpose but you would still need to introspect every single paragraph as they may have different leading values.

var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

var n = myParas.length;

while ( n-- ) {

myParas.leading = myParas.appliedParagraphStyle.leading;

}