2 Replies Latest reply on Jun 9, 2016 5:59 AM by Obi-wan Kenobi

    About Tabs! …

    Obi-wan Kenobi Adobe Community Professional

      Hi all,

       

      I've written this small (and without pretention) script to update "Note" paras ["Note" para style, to be applied to footnotes], updating the "indents"! …

      But i've found nothing about how to manipulate tabs!

       

      Sample: The "Note" para style tabulations by-default setting is:

                     tab 1: left tab at 5mm;      tab 2: right tab at 100mm.

       

      Paras has been modified and I have now:

      para 1:     tab 1: left tab at 8mm;     tab 2: left tab at 15mm;     tab 3: left tab at 18mm;     tab 4: right tab at 100mm.

      para 2:     tab 1: left tab at 3mm;     tab 2: left tab at 10mm;     tab 3: right tab at 80mm.

       

      Thanks in advance for any help!

       

      (function() {
          
          var myDoc = app.documents.item(0);
          var myNoteParaStyle = myDoc.paragraphStyles.item("Note");
          var myLeftIndent = myNoteParaStyle.leftIndent;
          var myRightIndent = myNoteParaStyle.rightIndent;
          var myFirstLineIndent = myNoteParaStyle.firstLineIndent;
      
      
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.appliedParagraphStyle = "Note";
          myFounds = myDoc.findGrep();
      
      
          for (var i = 0 ; i < myFounds.length ; i++) {
               myFounds[i].leftIndent = myLeftIndent;
               myFounds[i].rightIndent = myRightIndent;
               myFounds[i].firstLineIndent = myFirstLineIndent;
          }
      
      
      app.findGrepPreferences = app.changeGrepPreferences = null;
      
      
      }())
      
        • 1. Re: About Tabs! …
          Marc Autret Level 4

          Hi Obi-wan,

           

          ParagraphStyle and Paragraph objects (and, in fact, every Text object) manage tabs through their tabStops property, which addresses a collection of TabStop objects. So you will find anything you need in the TabStop(s) API, basically for parsing, adding, and removing tab stops. Essential settings come down to four properties:

           

          PropertyDescription
          .positionTab stop position, in current ruler units.
          .alignmentOne of TabStopAlignment enumerators (centerAlign, leftAlign, rightAlign, characterAlign.)
          .leaderTab stop leading string, if desired.
          .alignmentCharacterAlignment character (single character string) in case of TabStopAlignment.characterAlign.

           

          However, a good thing is that any text-related object also provide a tabList property, which is a shortcut for dealing quickly with those tab stops.

          myPara.tabList can be set to an array of objects so that you can instantly redefine the set of underlying tab stops. Here is a short example:

           

          // Boring constants
          // ---
          const TSA = TabStopAlignment,
                TB_LEFT   = +TSA.LEFT_ALIGN,
                TB_CENTER = +TSA.CENTER_ALIGN,
                TB_RIGHT  = +TSA.RIGHT_ALIGN,
                TB_CHAR   = +TSA.CHARACTER_ALIGN;
          
          // Some settings
          // ---
          var myTabs = [
              { position: 15,  alignment: TB_LEFT },
              { position: 25,  alignment: TB_CENTER },
              { position: 40,  alignment: TB_RIGHT,  leader: '.' },
              { position: 50,  alignment: TB_CHAR,   alignmentCharacter: ',' }
              /*etc*/
              ];
          
          // and boom!
          // ---
          myPara.tabList = myTabs;
          

           

          In your case you will use something like

           

          var myTabsForPara1 = [
              { position:   8,  alignment: TB_LEFT  },
              { position:  15,  alignment: TB_LEFT  },
              { position:  18,  alignment: TB_LEFT  },
              { position: 100,  alignment: TB_RIGHT }
              ];
          

           

          and so on.

           

          @+

          Marc

          • 2. Re: About Tabs! …
            Obi-wan Kenobi Adobe Community Professional

            Merci Marc ! Cela va m'aider !! Je te tiens au courant de la suite du script !!!