4 Replies Latest reply on Sep 24, 2013 1:04 AM by Sathya Rani M

    Reg. Bold Formatting apply to the text

    Sathya Rani M

      Hi All,

       

      Can anybody help me out to sort this issue. I need to apply the bold formatting to the specific text of the textframe contents.

       

      Here is the scenario.

       

          var seq = 0;

          var doc = app.activeDocument;

          np = doc.pages.add();

          marg = np.marginPreferences;

          gb = [marg.top, marg.left,

          doc.documentPreferences.pageHeight - marg.bottom,

          doc.documentPreferences.pageWidth - marg.right];

          oldRuler = doc.viewPreferences.rulerOrigin

          doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

          var aqFrame = doc.pages[-1].textFrames.add();

          aqFrame.geometricBounds = gb;

          previousTextFrame = doc.pages[-2].textFrames[0];

          for (var aq in aqCont) // aqCont Array have contents

          {

              seq = (aq*1)+1;

              aqFrame.contents += "Q"+seq+"\t"+"Au:"+"\t"+aqCont[aq]+"\n";

          }

          doc.viewPreferences.rulerOrigin = oldRuler

       

      In this i need "Q"+seq i.e Q1, Q2, Q3.... alone should be bold.

       

      Needed output:

      Q1     Au:     text1

      Q2     Au:     text2

       

      Any help is greatly appreciated. Thanks in advance.

       

      ~Sathya Rani M

        • 1. Re: Reg. Bold Formatting apply to the text
          Jump_Over Level 5

          Hi,

           

          I suggest to apply "bold" to each "Q\d+" occurrence in this textFrame's contents.

          It could be in paragraph style's definition (nested Grep) or made by Find...Change (by script or manually).

           

          Jarek

          1 person found this helpful
          • 2. Re: Reg. Bold Formatting apply to the text
            Sathya Rani M Level 1

            Hi,

             

            Thank you for the reply and this could be fine to apply paragraph style to every occurance of "Q\d+" by grep.

             

            By doing this way, the tool can execute at each line of document but in my case these occurances are exist only in the last page. So I have searched a way to apply bold while adding contents itself, also this will be helpful in fasting our execusion.

             

            I think there is no way other than you suggested! -- Thank you.

             

            ~Sathya Rani M

            • 3. Re: Reg. Bold Formatting apply to the text
              Jump_Over Level 5

              Hi,

               

              If there is not a separate paraStyle for those content you can make it straight forward

              (charStyle "Bold" is defined):

               

              sBold = doc.characterStyles.item("Bold");
              aqFrame.paragraphs.everyItem().nestedGrepStyles.add({
                   appliedCharacterStyle: sBold,
                   grepExpression: "^Q\\d+"
                   });
              

               

              executing after content is placed

               

              Jarek

              • 4. Re: Reg. Bold Formatting apply to the text
                Sathya Rani M Level 1

                Hi,

                 

                Great! It is working fine for me now. Thank you.

                 

                I have changed the characterStyle as below.

                 

                    var sBold = doc.characterStyles.item("B"); // Instead of Bold

                    aqFrame.paragraphs.everyItem().nestedGrepStyles.add({

                    appliedCharacterStyle: sBold,

                    grepExpression: "^Q\\d+"

                    });

                 

                Once again thank you for assisting me in a right way...

                 

                ~Sathya Rani M

                1 person found this helpful