Skip to main content
Known Participant
July 31, 2017
Answered

Change leading value

  • July 31, 2017
  • 2 replies
  • 1774 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 8, 2017

I did it:

var mySel = app.selection[0];

var myEveryGroup = mySel.groups.everyItem().allPageItems;

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

        for (var j = 0; j < myEveryGroup.length; j++) 

        { 

                myEveryGroup instanceof TextFrame && myEveryGroup.paragraphs.everyItem().leading = 14; 

            } 

}

To change the leading to a specific number, but don't know how to do with "appliedParagraphStyle" method.

RibnogAuthor
Known Participant
August 8, 2017

Any light [Jongware]​ ? I mentioned you because maybe Loic.Aigon is busy.

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;

}