View Single Post
  #2  
Old December 30th, 2021, 02:14 PM
Susan Susan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Maitland, FL
Posts: 65
Default Re: Trimming Text based on character count

I've used this rule which uses the width of your text box and will break the email address if it doesn't fit.


// Use TextMeasure to get the length of each email
var tm = new FusionProTextMeasure;
var frameWidth = 2.5; // set width of the text box (in inches)
tm.pointSize = "10 pt"; // set the type size
tm.font = "Calibri"; // set your typeface
var str = Field("email address"); // set the field to use
tm.CalculateTextExtent(str);
tm.useTags = false;
var tmWidth = tm.textWidth;

return (tmWidth < frameWidth*7200) ? str : str.replace("@unecessarilylongdomain.com", "<br>@unecessarilylongdomain.com");
__________________
FusionPro Creator v10.1.11 / FusionPro Producer / FusionPro Expression 3.2.2 / Mac OSX 10.14.6 / Acrobat Pro DC
Reply With Quote