Copy link to clipboard
Copied
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.
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
}
Copy link to clipboard
Copied
myPara.leading = myPara.appliedParagraphStyle.leading;
Copy link to clipboard
Copied
And the var myPara would be? I tried app.activeDocument.stories.everyItem but not work.
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
Works!
Yeah I forgot to say that are various paragraph styles with different leadings. Sorry...
Thank you!
Copy link to clipboard
Copied
Hi! I'm back!
I'm trying to apply this method only in a selected group with various elements, even other groups, include text frames that where my paragraphs are using selection[0] but I saw that this is not the way. I don't want to ungroup...
How I can achieve this?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I tried this, but nothing...
var mySel = app.selection[0];
var myEveryGroup = mySel.groups.everyItem().allPageItems;
var myParas = myDoc.stories.everyItem().paragraphs.everyItem().getElements();
for(var i = 0; i < myEveryGroup.length; i++)
{
for (var j = 0; j < myEveryGroup.length; j++)
{
myEveryGroup
}
}
Copy link to clipboard
Copied
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
}
}
To change the leading to a specific number, but don't know how to do with "appliedParagraphStyle" method.
Copy link to clipboard
Copied
Any light [Jongware]​ ? I mentioned you because maybe Loic.Aigon is busy.
Copy link to clipboard
Copied
Hi,
var myGroup = app.selection[0];
// Building an array:
var myGroupItems = myGroup.pageItems.everyItem().getElements();
myGroup.ungroup();
// If you like a selection of the ungrouped items:
app.select(myGroupItems);
var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();
var n = myParas.length;
while ( n-- ) {
myParas
}
myObj = app.selection;
app.activeWindow.activePage.groups.add(myObj);
Thanks
Copy link to clipboard
Copied
Ribnog wrote
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.
Hi,
if you are after all items stored in app.selection[0] (I suppose a group of items of unknown depth with a nested structure) just get them like that:
var arrayOfPageItems = app.selection[0].allPageItems;
Then loop the items for text frames. Something like that:
var arrayOfPageItems = app.selection[0].allPageItems;
for(var n=0;n<arrayOfPageItems.length;n++)
{
if(arrayOfPageItems
.getElements()[0].constructor.name != "TextFrame"){continue}; arrayOfPageItems
.parentStory.texts[0].leading = 14; };
Hope, that helps…
What I did not understand:
What do you mean by "how to do with "appliedParagraphStyle" method"?
Would you like to apply the new leading value only to paragraphs, that are formatted with a distinct paragraph style?
And if yes, would you like to have a locale override with leading? If not, just change the paragraph style…
Uwe
Copy link to clipboard
Copied
Hi Laubender​
I need to use the script in groups that I have to increase the size to 200%, so when I do that the text increases too. So to not have to ungroup them and apply your styles with your correct leading and pointSize (yes, I will need to change the size of the text too) I will need this.
So the appliedParagraphStyle is because in those groups I have text frames with differents text sizes and leadings and all of them have your own style so to not change one by one I think is more easy apply your respective styles to back to your right properties.
I think override.ALL works, but if some text have italic will miss it.
I hope you understand, my english is not very good.