1 Reply Latest reply on Mar 29, 2008 12:54 AM by (Robert_Tkaczyk)

    URGENT! HELP! Text Frame using script

    Level 1
      Hi there,

      I have to use some text in many files for which I created one script. Clicking it will automatically adds a text frame with some text. I have almost reached with what I want but still not completely. Following issues I couldn't able to solve.

      1)The geometricbounds I gave is for letter page size. It's working. But If I have less than letter size page this will not run. I want this to capture the current/active page height and width and create the text frame at the bottom of the active page (not first page) with 0.5 margin all over with the text. Can this be possible?

      2)I need to give the color for the font. I tried "myTextFrame.font.colors" but not working.

      3)The text has three paragraphs with two/three lines and I need to give paragraph space before or after for each like 0.5.

      Below is my script. Please help!

      var myTextFrame = app.activeWindow.activePage.textFrames.add()
      var myParagraph = myTextFrame.paragraphs.item(0)
      var myFont = app.fonts.item("Arial")
      myTextFrame.geometricBounds = ["11.2in", "6.5in","10.3in","0.5in"];
      myTextFrame.contents = "Sample Text - Em adipsusci tionsequip et wissiscilis adigniscilis del delit praessi.
      Xer irit aliscing et luptatie exerostrud do exercipit nosto commolor ip ecte deliquis do odolesenim alit ad do con hent alit in utat illa consenisi.San vullaore eugait loreet et ad dolor suscidunt praese magna facipit iusto doloreet lum";
      myParagraph.parentStory.appliedFont = myFont
      myParagraph.parentStory.pointSize = 7.5
      myTextFrame.fit(FitOptions.frameToContent)

      Your help is really appreaciated. Thanks in Advance.
        • 1. Re: URGENT! HELP! Text Frame using script
          Level 1
          I'm not JS man but info from VB should help you (remember - JS is CaseSensitive):

          1)

          Property Bounds As Variant
          read-only
          Member of InDesign.Page
          The bounds of the Page, in the format [y1, x1, y2, x2]. as Array of 4 Units (Doubles or Strings)

          myTextFrame.GeometricBound = myPage.Bounds
          ' this will resize TextFrame to Page size


          2)

          Property FillColor As Variant
          Member of InDesign.Text
          The swatch (color, gradient, tint, or mixed ink) applied to the fill of the Text. as Swatch or String

          myTextFrame.ParentStory.Texts.Item(1).FillColor = myColor


          3)

          Property SpaceAfter As Variant
          Member of InDesign.Text
          The height of the paragraph space below. as Unit (Double or String)
          Property SpaceBefore As Variant
          Member of InDesign.Text
          The height of the paragraph space above. as Unit (Double or String)

          myTextFrame.ParentStory.Texts.Item(1).SpaceBefore = 0.5
          myTextFrame.ParentStory.Texts.Item(1).SpaceAfter = 0.5
          ' set to all text

          myTextFrame.ParentStory.Paragraphs.Texts.Item(1).SpaceBefore = 0.5
          myTextFrame.ParentStory.Paragraphs.Texts.Item(-1).SpaceAfter = 0.5
          ' set before text and after text
          ' only to first (before) and only to last (after) paragraph in text

          robin

          --
          www.adobescripts.com