1 Reply Latest reply on Mar 28, 2013 6:14 AM by Jump_Over

    Find H1 style in Top of Frame only

    BEGINNER_X Level 3

      Hi Everyone,

       

      Request:

       

      I want to find "H1" style in top of frame only. It is two column book.

       

      If "H1" style comes in both the columns 1 and 2.

       

      Problem:

       

      Document using span columns, so the script will find all the  H1 style falls in first line of every column.

       

       

      Trying script in  ways:

       

      var myDoc = app.activeDocument

      app.activeDocument.viewPreferences.horizontalMeasurementUnits = app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

      var myTextFrame = myDoc.textFrames.everyItem().getElements()

       

      for(i=0; i<myTextFrame.length; i++)

      {

              if(parseInt(myTextFrame[i].geometricBounds[3] - myTextFrame[i].geometricBounds[1]) == 180)

          {

          for(j=0; j<myTextFrame[i].textColumns.length; j++)

          {

              if(myTextFrame[i].textColumns[j].lines[0].appliedParagraphStyle.name == "H1")

              {

                  alert("H1 in First line of Frame\n"+ "Contents:" + myTextFrame[i].textColumns[j].lines[0].contents + "Page number: " + myTextFrame[i].textColumns[j].lines[0].parentTextFrames[0].parentPage.name)

                  app.select(myTextFrame[i].textColumns[j].lines[0].parentTextFrames[0])

                  exit(0)

                 

                  }

              }

          }

      }

       

      Could anyone please give solution.

       

      Kindly check the screenshot

       

      Screen Shot 2013-03-28 at 4.12.12 PM.png

       

      Thanks in advance

      Beginner_x

        • 1. Re: Find H1 style in Top of Frame only
          Jump_Over Level 5

          Hi,

          A solution could be to compare .endBaseline properties.

          i.e.:

          myTextFrame[i].textColumns[0].lines[0].endBaseline ==> this could be a base for textFrame [i]

           

          so make the next if startement with two conditions:

          - proper paraStyle

          - proper endBaseline of 1st line of x textColumn (equal or "no higher then...")

           

          rgds

          Jarek

          1 person found this helpful