Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Find H1 style in Top of Frame only

Enthusiast ,
Mar 28, 2013 Mar 28, 2013

Copy link to clipboard

Copied

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.geometricBounds[3] - myTextFrame.geometricBounds[1]) == 180)

    {

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

    {

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

        {

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

            app.select(myTextFrame.textColumns.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

TOPICS
Scripting

Views

391
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 28, 2013 Mar 28, 2013

Copy link to clipboard

Copied

LATEST

Hi,

A solution could be to compare .endBaseline properties.

i.e.:

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

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines