1 Reply Latest reply on Sep 10, 2014 4:40 AM by Chinnadk

    I need to select all text frames in a document and to align text frames in verso pages to left margin and text frames in recto pages to right margin.

    harish9003

      Hi,

       

      Am new to Java scirpt.

       

      Can any one help me over here, I need to select all text frames in a document and to align text frames in verso pages to left margin and text frames in recto pages to right margin.

       

      Thanks,
      Harish

        • 1. Re: I need to select all text frames in a document and to align text frames in verso pages to left margin and text frames in recto pages to right margin.
          Chinnadk Level 4

          Hi Harish,

           

          Try this.

           

          var doc =app.activeDocument,
              _pages = doc.pages;
          doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;   
          for(var i =0;i<_pages.length;i++)
          {
                  txfms = _pages[i].textFrames.everyItem().getElements();
                  for(var j =0;j<txfms.length;j++)
                  {
                      if(_pages[i].documentOffset % 2 == 1)
                      {
                              var leftm  = _pages[i].marginPreferences.left,
                                  framtoppos = txfms[j].geometricBounds[0];
                              txfms[j].move([leftm,framtoppos])
                          }
                      else
                      {
                              var rightm  = _pages[i].marginPreferences.right,
                                  w = doc.documentPreferences.pageWidth,
                                  fmwidth = txfms[j].geometricBounds[3] - txfms[j].geometricBounds[1];
                              txfms[j].move(txfms[j].parentPage.name,[w-rightm-fmwidth-txfms[j].geometricBounds[1],0])
                          }
                  }
              }
          

           

          Regards,

          Chinna