3 Replies Latest reply on Apr 9, 2008 3:06 AM by (priyan)

    How to give Bold style inside Single Text Frame

      Hi

      I created a text frame with some text in it. It comes in three paragraphs. First para is the title with two words and below two are small description. All the text is kept in single textframe and I need that to be in single frame only. NOW, I need to bold the first para that is the title with two words. How can I write the code to give bold style to the first paragraph inside that frame? Do I need to take different frame? I want all in single actually. Also I want the entire text frame to give my customized text color.

      Hoping a valuable suggestion

      Thanks in advance.

      Regards
      P
        • 1. Re: How to give Bold style inside Single Text Frame
          Level 1
          Give us a hint: which version of InDesign? Which scripting language? What have you tried so far? How does the script know which text frame to operate on?

          Why aren't you using Paragraph styles to do the formatting without the need for a script at all?

          Dave
          • 2. Re: How to give Bold style inside Single Text Frame
            Level 1
            Dave, Good questions(s)!!! Details below...
            It's CS2. I need to put some text in all (many) documents I work regularly. Instead of copying from the previous file or any other source, as the text is same for all, I thought of writing the script with the text itself. Running that will create text frame and write the text. Got almost but was unable to bold the title of the text which I mentioned earlier as a first paragraph with two words.

            Also I couldn't give the my color swatch to the text.

            Here is my script:

            var myTextFrame = app.activeWindow.activePage.textFrames.add()
            var myParagraph = myTextFrame.paragraphs.item(0)
            var myFont = app.fonts.item("Arial")
            myTextFrame.geometricBounds = ["11.2in", "6in","9.57in","0.5in"];
            myTextFrame.contents = "First Paragraph"
            myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r This is Second paragraph.";
            myTextFrame.parentStory.insertionPoints.item(-2).contents = "\r\rHere comes the Third Paragraph with extra para space";
            myParagraph.parentStory.appliedFont = myFont
            myParagraph.parentStory.pointSize = 8
            myParagraph.paragraphs.item(-1).spaceAfter = "0.05in"
            myTextFrame.fit(FitOptions.frameToContent)

            Hope this answers all your questions. Waiting for valuable solution. Have another question will ask after I got this. For now, two questions 1) making bold first two words 2) font color
            • 3. Re: How to give Bold style inside Single Text Frame
              Dear Prasant

              please check the following coding may be this will help you:

              var myTextFrame = app.activeWindow.activePage.textFrames.add()
              var myParagraph = myTextFrame.paragraphs.item(0)
              var myFont = app.fonts.item("Arial")
              myTextFrame.geometricBounds = ["11.2in", "6in","9.57in","0.5in"];
              myTextFrame.contents = "First Paragraph"
              myTextFrame.parentStory.insertionPoints.item(-1).contents = "\rThis is Second paragraph.";
              myTextFrame.parentStory.insertionPoints.item(-2).contents = "\r\rHere comes the Third Paragraph with extra para space";
              myParagraph.parentStory.appliedFont = myFont
              myTextFrame.paragraphs[0].fontStyle = "Bold"
              myParagraph.parentStory.pointSize = 8
              myParagraph.paragraphs.item(-1).spaceAfter = "0.05in"
              myTextFrame.fit(FitOptions.frameToContent)

              Regards
              Priyan