Dmiller35 Posted December 30, 2021 Share Posted December 30, 2021 I have a document that has a limited amount of space and one of the fields is an email address. I can do a copyfit, but in order to keep everything on one line, the font has to go from 9pt down to 5 on some records. (The client's domain name is stupidly long). Is there a way to splt the email at the "@" so that when it's longer that 32 characters, it drops the "@unecessarilylongdomain.com" down to a second line? Every record has the same domain name so is there a way to trim the right 25 characters? This way jonathan.doe@unecessarilylongdomain.com would become jonathan.doe @unecessarilylongdomain.com Quote Link to comment Share on other sites More sharing options...
Susan Posted December 30, 2021 Share Posted December 30, 2021 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"); Quote Link to comment Share on other sites More sharing options...
jwhittaker Posted December 31, 2021 Share Posted December 31, 2021 D Miller You could try something like this? I know there is a more efficient way but this should still work. if (Len(Field("Email")) >= 32) { var emailarray = Field("Email").split("@"); return emailarray[0] + '<p>' + "@" + emailarray[1]; } else return Field("Email"); Quote Link to comment Share on other sites More sharing options...
Dmiller35 Posted January 6, 2022 Author Share Posted January 6, 2022 Thanks Susan. That worked great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.