3 Replies Latest reply on Mar 6, 2009 1:42 PM by sstanleyau

    AppleScripting an InDesign Paragraph Style

      There may be a better way to do this, but the workflow was created before being handed over to me.
      Basically, there is an existing AppleScript to paginate a product in InDesign, but the Paragraph Style Sheet line in AppleScript is very basic & uses the wrong font!
      There is an example:

      on SetTextStyles()
      tell application "Adobe InDesign CS2"
      tell active document
      try
      set firstLineStyle to paragraph style "FirstLine"
      on error
      set firstLineStyle to make new paragraph style with properties {name:"FirstLine", point size:6, font:"Arial Narrow"}
      end try

      What this 'firstLineStyle' should relly look like is this (based on the InDesign info):
      FirstLine
      [Basic Paragraph] + next: [Same style] + BentonGothicCond + Bold + size: 8 pt + leading: 9.5pt + tracking: -20 + pair kern method: Optical + tabs: count = 1, [position: 140 pt, alignment: right]

      I get scripting errors when I have tried (still learning AppleScript), things like the 'pair kern method' & 'tab counts' are not well liked.
      Can someone tell me what I need to do to get this to work?

      Thanks for any help.
        • 1. Re: AppleScripting an InDesign Paragraph Style
          sstanleyau Level 4
          Your first potential problem is that you're making the styles in the<br />application, not in a document. are you sure you want to do that?<br /><br />The best way to find out what you want is to ask for the properties you<br />want. So:<br /><br /> properties of paragraph style "FirstLine"<br /><br />Add "of document 1" if that's what you mean. Copy the result, and just<br />delete any that you don't want.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>
          • 2. Re: AppleScripting an InDesign Paragraph Style
            Level 1
            Well, I was given this, and it almost worked!
            Type is formatted spot-on, but the tab info is not included!
            Any idea's on the correct syntax for tabs?

            on SetTextStyles()
            tell application "Adobe InDesign CS2"
            tell active document
            try
            set firstLineStyle to paragraph style "FirstLine"
            on error
            set firstLineStyle to make new paragraph style with properties {name:"FirstLine"}
            end try

            try
            set applied font of firstLineStyle to "BentonGothicCond"
            set font style of firstLineStyle to "Bold"
            set point size of firstLineStyle to 8
            set leading of firstLineStyle to 9.5
            set tracking of firstLineStyle to -20
            set kerning method of firstLineStyle to "Optical"
            set tab list of firstLineStyle to [{position:140, alignment:right}]
            end try

            end tell
            end tell
            end SetTextStyles
            • 3. Re: AppleScripting an InDesign Paragraph Style
              sstanleyau Level 4
              I can't recall whether CS2 had tab lists, or whether you had to make tab<br />stops, but the alignment should probably be "right alignment" (no quotes).<br />Otherwise, try this:<br /><br />make tab stop at firstLineStyle with properties {position:140,<br />alignment:right align}<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>