3 Replies Latest reply on Jun 28, 2011 10:11 PM by Napo Monasterio

    How to apply paragraph style to all paragraphs

    Napo Monasterio

      Hi folks,

       

      Simple question. New to JS scripting here (but loving it so far).

       

      I'm trying to apply a paragraph style (myTextStyle) to all the paragraphs in a story.

       

      Right now, I've got it set up as follows:

       

      tabletDocument.pages.item(0).textFrames.item("story").paragraphs.item(0).applyParagraphSty le(myTextStyle, true);

       

      Obviously, it's just doing the first paragraph — item(0) — but any alteration to the code throws it off.

       

      Can I set up either a range (first to last) or anything else to it so it will apply to all of them?

       

      Thanks in advance!

       

      N

        • 1. Re: How to apply paragraph style to all paragraphs
          John Hawkinson Level 5

          Just set the .appliedParagraphStyle property on the whole Story.

          • 2. Re: How to apply paragraph style to all paragraphs
            Napo Monasterio Level 1

            John,

             

            Thanks for the reply! Works great — thanks!

             

            I had tried that earlier, but I think I was doing it wrong, and thus it wasn't overriding the current styles. I think I was using an .RTF file, and so kept its own paragraph styles. I am now using a .TXT and it seems to be doing the trick.

             

            With the .appliedParagraphStyle , I guess it won't override, right? (Not that it matters... just wondering.)

             

            Thanks again!

             

            N

            • 3. Re: How to apply paragraph style to all paragraphs
              John Hawkinson Level 5

              No, your explanation does not sound right. When we talk about overrides,

              that is things like the font size or the justification that means that

              sub subset of a paragraph is overriding the specifications of the

              paragraph style.

               

              If you change the paragraph style, it changes the paragraph style, and

              there's no issue of overriding. You cannot override one paragraph style

              with another.

               

              (I suppose you might have text within the paragraph that already has

              overrides applied, but I don't think that's what you are talking

              about; you can easily see these by clicking in the text and then

              looking for a plus-sign in the Paragraph Styles panel next to the

              current style. And if you hover the mouse over it, it will tell you

              what the overrides are).