Jump to content

Line Counter

Recommended Posts

So I know how to measure the length of a string. I was wondering if there is a way to determine how many rows of text there are in a text frame or how much vertical space in a text frame is being filled?


Im trying to make templates that have responsive layouts that will change based on the amount of content entered.

Link to comment
Share on other sites

It won't tell you how many rows of text you have in a text frame, but the TextMeasure function will allow you to find the height (in 100th's of a point) of specified text – which is what I think you really need to determine how much space is being filled.


Here's a function that would probably work for your needs:

function getTextHeight(frameName){
   var text = FindTextFrame(frameName).content;
   text = text.replace(/<variable name="([^"]*)">/g,function(a,b){return RuleOrField(b);});
   var tm = new FusionProTextMeasure;
   tm.useTags = true;
   tm.maxWidth = GetSettableTextWidth(FindTextFrame(frameName));
   return tm.textHeight; // 7200 = 1 inch

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...