Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 4th, 2022, 02:45 PM
EricC EricC is offline
Regular Contributor
 
Join Date: Nov 2008
Posts: 88
Arrow Determine number of text lines

A text box is 2.25 inches wide.
Inside of that text box I have placed a field named 'Title'

Some titles are very long but the text box is tall enough to accommodate up to 5 lines.

Is there a function or rule I can use, that will return the number of lines for any given record as a result of word wrap?

For example:

'Title 1' will fit on one line therefore return '1'

'Here is Title 2 and it's a bit longer' - I want to know if this will end up wrapping to 2 lines or 3 lines. (That is, I want the rule to return '2' or '3')
Reply With Quote
  #2  
Old July 7th, 2022, 06:29 AM
jwhittaker jwhittaker is offline
Senior Contributor
 
Join Date: Feb 2009
Location: San Diego
Posts: 169
Default Re: Determine number of text lines

// Use TextMeasure to get the length of each company name
var tm = new FusionProTextMeasure;
var frameWidth = 2.25; // set width of the text box (in inches)
tm.pointSize = "10 pt"; // set the type size
tm.font = "Helvetica"; // set your typeface
var str = Field("Title"); // set the field to use
tm.CalculateTextExtent(str);
tm.useTags = false;
var tmWidth = tm.textWidth;
var tmNumberofLines = tm.textLines;

return tmNumberofLines;
__________________
FusionPro VDP Creator 10.0.26 | MacOS 10.13.4 | Acrobat DC
Reply With Quote
Reply

Tags
calculate, word wrap, wrap text

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:52 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.