Skip to main content
Participating Frequently
January 4, 2013
Question

Get the Paragraph Style of a parapraph

  • January 4, 2013
  • 2 replies
  • 830 views

Hello,

i am trying to write a script that iterate over all paragraphs of a document. My aim is to remove the returns between two paragraphs of the same style.

Therefore I have to read out the Paragaph Style of the single paragraphs I iterate over. I dont know how to read out the the Parapgraph Style. Can some one help me?

This is what I have so far:

function remove_returns() {

    for (var i = 0; myDoc.stories.length > i; i++) {

        for (var j = 0; myDoc.stories.paragraphs.length > j; j++) {

                paraStyle = myDoc.stories.paragraphs.getParagraphStyle(); // <- something like this would be great

        }

    }

}

If you have a complete solution for my problem, that would be awesome.

Thanks

This topic has been closed for replies.

2 replies

Jump_Over
Legend
January 4, 2013

Hi,

I suggest to iterate over textStyleRanges instead of paragraphs.

This way in each step you have a part of text ready to remove/replace returns.

It could be simple using:

     myTextStyleRange.changeText()

method inside your loop.

rgds

phodanaAuthor
Participating Frequently
January 4, 2013

Can you help me with this? I just started writing scripts for InDesign. I dont know how two archieve this.

phodanaAuthor
Participating Frequently
January 4, 2013

I got it working

Thanks for the changeText() hint.

Harbs.
Legend
January 4, 2013

paraStyle = myDoc.stories.paragraphs.appliedParagraphStyle

phodanaAuthor
Participating Frequently
January 4, 2013

Thanks, that helped.

Next Problem: How can I combine two paragraphs (so that I dont have the return between them)?