Jump to content

Adjusting text box size based on variable size

Eric Patrick

Recommended Posts

I looked at the attached job, but I couldn't figure out what you mean by "resize the Border based on the size of the variable." So I can't give you an algorithm, but in general, the answer is Yes, you can indeed adjust the width of a frame border. In OnRecordStart, access the named frame with FindTextFrame(), then set the returned FusionProTextFrame object's borderThickness property, in hundredths of points (7200 per inch). For instance:

FindTextFrame("YourFrameName").borderThickness = 7200; // one inch

Or did you mean that you want to resize the entire frame? That can be done as well, by setting the width and height properties, and you can also set the x and y properties to move a frame's position. However, you need to compose with a FusionPro VDP Producer or Server license to move and resize frames in this way.

Link to comment
Share on other sites

You just need to make a variable width table using TextMeasure:

var str = ToUpper(Field("City")) + ' SECURITY NOTICE';
var space = 900; // .125 inches == 900

function getTextWidth(input){
   var tm = new FusionProTextMeasure;
   tm.font = "Univers 65 Bold";
   tm.pointSize = "14pt";
   var result = tm.textWidth;
   return (result*1.1) + space*2;

var table = new FPTable();
var row = table.AddRow();
var cell = row.Cells[0]
cell.VAlign = "Middle";
cell.Margins = {'Left':space, 'Right': space, 'Top': space/10, 'Bottom': space/10};
return table.MakeTags().replace(/^\<table/, "<table alignment=center");


Here's a similar thread.

Link to comment
Share on other sites

  • 6 months later...

Hey Step,


A quick question on a post in this thread (#4). In your function getTextWidth(input), you're returning the tm.textWidth * 1.1. I get the space * 2 to get the 1/8 inch left/right margins the original poster said he wanted, but why multiply the textWidth * 1.1?


Just curious...





Link to comment
Share on other sites

That's a good question, Gregg. I don't really remember but if I had to guess, I'd say it was to include a little "wiggle room" in case the measurement of the text wasn't entirely accurate. I've noticed that sometimes if you set the width of the table to the exact width of the text, the text can occasionally overflow so multiplying the width by 1.1 just adds a 10% buffer.
Link to comment
Share on other sites

  • 2 years later...
  • 3 years later...

I'm fairly new to FP and I'm struggling. Hopefully someone cane help.


I have a text frame that has a black outlined border. Depending on the information of the text, the text frame may not be full. So there will be space at the bottom on some records and other records the box will be full.


What I would like to do is have the frame shrink up where the words would end and expand down when there are more words in the box.


Copyfit doesn't work fully in this situation, I don't want to smaller amount of words to expand to fill, I need it to stay the same size.


I attached 2 pictures to maybe help explain what i want to do.


I'm trying the ResizeFrame function, but I'm having trouble writing it. I'm missing something

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...