Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator


Thread Tools Search this Thread Display Modes
Old December 18th, 2017, 06:02 PM
lkain lkain is offline
Forum n00b
Join Date: Mar 2017
Location: Phoenix, AZ
Posts: 6
Question Possible to use CopyfitLine with "Do not break on copyfit"?

Hi all,

As the title indicates, I'm wondering if it's possible to modify the CopyfitLine code in such a way that the line will not break to multiple lines before trying to copyfit.

I currently have the javascript below:

return CopyfitLine("", Field("contactName"), "Helvetica Neue", 9.5, 105.35, 7, false);
However, because I have plenty of room in my text box for the line to break, and because there's a space in the field value ("Firstname Lastname"), it's breaking at the space before it attempts to copyfit. I have "Do Not Break On Copyfit" selected in my text box, but I am guessing that only works on the normal OnCopyfit rule, and not on CopyfitLine.

Is there a javascript function (or other solution) I can use to ensure the line does not break at the space? I should mention, using a non-breaking space isn't a great solution for us, as more often than not, FusionPro will spit out boxes with Xs in them in composition whenever a non-breaking space is used (but that's a different issue altogether).

Any help is appreciated!
Reply With Quote
Old December 18th, 2017, 06:15 PM
lkain lkain is offline
Forum n00b
Join Date: Mar 2017
Location: Phoenix, AZ
Posts: 6
Question Re: Possible to use CopyfitLine with "Do not break on copyfit"?

As a quick follow-up... out of curiosity, I removed the space in the field value, and while the copyfit did occur, it is still breaking to two lines, even though it could copyfit to a lower point size.

The javascript validates to the below:
<f name="Helvetica Neue"><z newsize=9.5><z newsize=7.800000000000006>EdwardHanrahanhfewfwerewr
However, I have in my rule to allow it to copyfit down to 6.5pt. I can't figure out why it stops at 7.8pt and continues to want to break.

As an aside, I have the same rule being applied to another field (email address) in the same text box, and the email address version works flawlessly. Is it possible the two rules are conflicting with one another?

Reply With Quote
Old December 18th, 2017, 08:03 PM
step's Avatar
step step is offline
Senior Contributor
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Possible to use CopyfitLine with "Do not break on copyfit"?

It seems a little excessive, but you could use FusionProTextMeasure:
var contactName = 'Edward Hanrahanhfewfwerewr';
var pointSize = { max: 9.5, min: 6.5 };
contactName = '<span font="Helvetica Neue" pointsize="' + pointSize.max + '">' + contactName + '</span>';
var limit = Int((pointSize.min / pointSize.max) * 100);
return NoBreakCopyfit(contactName, 100, limit);

function NoBreakCopyfit(str, mag, min) {
  if (FusionPro.inValidation) return str;
  try {
    var frameName = FusionPro.Composition.CurrentFlow.name;
    var width = GetSettableTextWidth(FindTextFrame(frameName));
  } catch(e) {
    ReportError('Must name text frame and set rule to "Re-evaluate this rule for every text flow"');
  var tm = new FusionProTextMeasure;
  tm.useTags = true;
  tm.maxWidth = width;
  var magnified = '<magnify factor="' + mag + '" type="text">' + str + '</magnify>';
  return tm.textLines > 1 && mag > min ? NoBreakCopyfit(str, --mag, min) : magnified;
Make sure you name your text frame and set the rule to "Re-evaluate this rule for every text flow."
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

Reply With Quote

break, copyfit, copyfitline

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 07:04 AM.

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