2 Replies Latest reply on Jun 17, 2014 1:58 AM by Laubender

# Measuring distance between baseline of last line in text column and end of text frame

I am new to InDesign CC scripting and i don't know how to do this script. I need a javascript that allows me to measure the distance between  the Baseline of the last line in textcolumn and the bottom of text frame.

Any help i will be grateful.

Thanks,

• ###### 1. Re: Measuring distance between baseline of last line in text column and end of text frame

Hi,

Try this.

```var baseline = app.selection[0].lines[-1].baseline;
var gb = app.selection[0].geometricBounds;
```

Regards,

Chinna

• ###### 2. Re: Re: Measuring distance between baseline of last line in text column and end of text frame

@Chinnadk – hm, shouldn't we factor in baselineShift of single characters on that line?

As it seems asking for the value of baseline for a line of text will return the value from the first character in that line. Maybe that is important for the OP. Depends on what Mohamed Yousif likes to accomplish with the value of the distance.

Also: text could be rotated inside the text frame; text frame could be rotated. So the y-value of the position could be different for every insertion point on that line.

See following basic situation; text or text frame not rotated; some characters in the last line of text column 1 are shifted down by 10 pt.

Following code will get -2.82967053835213 as the distance if we look at text column 1 of the selected text frame:

```//TextFrame selected
//Get baseline for every character in the last line of text column 1:
var myBaselines = app.selection[0].textColumns[0].lines[-1].characters.everyItem().baseline;
var biggestBaselineNumber = myBaselines.sort(numericSortFromHighestToLowest)[0];

var gb = app.selection[0].geometricBounds;
\$.writeln("Distance: "+ (gb[2] - biggestBaselineNumber));

//Result in my example: -2.82967053835213 in my local meassurement system (in this case mm)

function numericSortFromHighestToLowest(b,a){return Number(a) - Number(b);};
```

So what will you expect, if you meassure the distance?
Would you need the nearest distance from the shifted characters?

Uwe