MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   FusionPro® VDP Producer (formerly FusionPro® Direct) (http://forums.pti.com/forumdisplay.php?f=14)
-   -   How To Control Where Line Breaks? (http://forums.pti.com/showthread.php?t=3406)

Meir May 1st, 2013 12:44 PM

How To Control Where Line Breaks?
 
I am working on a business card that has very specific design specifications. One of the specifications is if the email cannot fit on one line, to drop the @... to the next line.

short@client.com would fit on one line but

reallyreallyreallyreallylong@client.com would display as

reallyreallyreallyreallylong
@client.com

Is there a way to set where the line breaks? In this case, set it to break before the @ symbol.

Thank you.

step May 1st, 2013 01:01 PM

Re: How To Control Where Line Breaks?
 
You can give this a shot:
Code:


// Use TextMeasure to get the length of each company name
var tm = new FusionProTextMeasure;
var frameWidth = 2; // 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("Email"); // set the field to use
tm.CalculateTextExtent(str);
tm.useTags = false;
var tmWidth = tm.textWidth;

return (tmWidth < frameWidth*7200) ? str : str.replace("@", "<br>@");


Meir May 1st, 2013 01:17 PM

Re: How To Control Where Line Breaks?
 
Thank you very much. That worked great!

Meir May 1st, 2013 02:36 PM

Re: How To Control Where Line Breaks?
 
I ran into an error trying to make a more complicated version of that. When I did it with the email field, it worked fine.

Now I am trying to adapt it to work with multiple fields.

I need it to determine if a line made up of first last credential1, credential2, credential3, credential 4 is wider than the text box.

If so, I need it to break the line after the first name, so the last name starts a new line.

I tried this:

Code:

var frameWidth = 1.62; // set width of the text box (in inches)

// Use TextMeasure to get the length of each company name
var names = new FusionProTextMeasure;
names.pointSize = "9 pt"; // set the type size
names.font = "Bosis Bold"; // set your typeface
var strnames = Field("First")+" "+Field("Last"); // set the field to use
names.CalculateTextExtent(strnames);
names.useTags = false;
var namesWidth = names.textWidth;

// Use TextMeasure to get the length of each company name
var credential = new FusionProTextMeasure;
credential.pointSize = "9 pt"; // set the type size
credential.font = "Bosis Light"; // set your typeface
var strcredential = " "+Rule("Credential Rule"); // set the field to use
credential.CalculateTextExtent(strcredential);
credential.useTags = false;
var credentialWidth = credential.textWidth;


return (namesWidth+credentialWidth < frameWidth*7200) ? strnames : strnames.splice(" ", "<br>");

However, this is returning "{Name Copyfit Rule}" rather than the name.

Dan Korn May 1st, 2013 02:44 PM

Re: How To Control Where Line Breaks?
 
Quote:

Originally Posted by Meir (Post 12956)
However, this is returning "{Name Copyfit Rule}" rather than the name.

You should see the error when you validate the rule in the Rule Editor, and also in the .msg file when you do a regular composition (not a Preview).

Meir May 1st, 2013 03:10 PM

Re: How To Control Where Line Breaks?
 
when I validate in the rule editor, it gives me the result I want.

When I compose, I get this error
Quote:

Name Copyfit Rule, line 22: TypeError: strnames.splice is not a function
Composing record #1, input record 1
Value for variable Name Copyfit Rule not found in instance data
So I figured out it was because I replaced 'str.replace' with 'strnames.splice'.

Thank you.


All times are GMT -7. The time now is 02:30 AM.

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