Jump to content

Adjust graphic to line of text


rsager

Recommended Posts

Posted

I am trying to create an inline graphics rule that will adjust the width of a tif file to the length of my Fname, MI, Lname and Education Fields in a business card template. If the name line has 19 characters the lines.tif will match the width of characters. I think I am on the right track but I am having some trouble setting it up. Can this be done as an inline graphics rule?

Posted

I've never done anything like that before, but at a glance it seems like this could be handled with the TextMeasure object. I haven't tried the following code, but perhaps it will at least get you started:

var myText = Field("Fname") + " " + Field("MI") + " " + Field("Lname") + ", " + Field("Education");

var tm = new FusionProTextMeasure;

// CHANGE THESE TO MATCH YOUR TEXT ATTRIBUTES
tm.pointSize = "12 pt";
tm.font = "Arial";
tm.bold = true;
tm.useTags = false;
tm.CalculateTextExtent(myText)

var graphicWidth = tm.textWidth;
var result = <graphic file=\"lines.tif\" width=graphicWidth>;

Posted

Thanks Eric,

Shawn was able to help me out. Created a Rule called Inline Graphic Rule. Here is the code.

 

wholeGroup='<p style="(no style)" br="false" override="true" quad="C" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="2" kerning="true" hyphenate="true" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false"><tracking newsize="0.000000"><f name="Palatino Black"><z newsize="18.0"><color name="Black"><b><variable name="FName"> <variable name="MI"> <variable name="LName">, <variable name="Education">';

TM = new FusionProTextMeasure;

TM.CalculateTextExtent(wholeGroup);

myTM=TM.textWidth;

return '<graphic file="lines.tif" width="'+myTM+'" height="3675">';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...