Jump to content

Auto-adjusting size of just one line of text in a TextFrame


NAFPRm

Recommended Posts

I'm a code novice, so bear with me.

 

I have a text frame with several lines of data being pulled from a CSV.

 

EXAMPLE:

Line 1

Line 2

Line 3

 

Line 3 can get to be exceptionally longer than the others and exceed the width of the TextFrame. I want this line to automatically change size to fit within the width of the TextFrame without affecting the size of the other lines of data.

 

I've messed around with various Copyfit and CopyfitLine configurations, but nothing has worked. Any advice/suggestions appreciated.

Link to comment
Share on other sites

I had to do this as well for a name badge scenario but it took some testing to make sure it was just right. I made a new Empty JavaScript rule for each line.

 

In my text frame I have:

«First_CopyFit»

«LastName_CopyFit»

«Organization»

 

The last names seemed to be longer than the others so I will provide the code for the LastName_CopyFit rule I created.

 

//this JavaScript will apply all cap formatting to the "Last"  field.
var uppercaseLast = ToUpper(Field("Last"));

//this checks for syntax in the string.
var hyphenCheck = uppercaseLast.indexOf("-");
var spaceCheck = uppercaseLast.indexOf(" ");
var lineCheck = uppercaseLast.indexOf("~");

//If syntax exists use uppercase, correct syntax and fit it to line.
//No static text, use break from IF/ELSE, based on specific font from list, 
//make the base font 24 points, width of space 125 points and minimum 
//of 48 points (did not adjustWidthOnly true/false). 
//Check for hyphens and split the hyphenated name onto a new line
if (hyphenCheck >=1)
{
   var addBreak = uppercaseLast.replace("-", "-<br>")
   return CopyfitLine("", addBreak, "Myriad Pro Cond", 48, 125, 24);
}
//Check for a space and make sure that it doesn't break to a new line
else if (spaceCheck >=1)
{
   var addSpace = uppercaseLast.replace(" ", " ")
   return CopyfitLine("", addSpace, "Myriad Pro Cond", 48, 125, 24);
}
//Check for a line break designated as tilde and change to break       
else if (lineCheck >=1)
{
   var addLine = uppercaseLast.replace("~", "<br>")
   return CopyfitLine("", addLine, "Myriad Pro Cond", 48, 125, 24);
}

else
{
   return CopyfitLine("", uppercaseLast, "Myriad Pro Cond", 48, 125, 24);
}

 

With this I noticed that the "font name" wasn't exactly as it was listed in my fonts so I used what was listed in FusionPro.

 

Also, the font sizing works best if you check the longest line and the shortest line for the best fit and adjust the numbers as needed.

 

This is the original thread I used to help get me started:

http://forums.pti.com/showthread.php?t=1712

Edited by Landisa
Prevent scrolling
Link to comment
Share on other sites

I'm a code novice, so bear with me.

 

I have a text frame with several lines of data being pulled from a CSV.

 

EXAMPLE:

Line 1

Line 2

Line 3

 

Line 3 can get to be exceptionally longer than the others and exceed the width of the TextFrame. I want this line to automatically change size to fit within the width of the TextFrame without affecting the size of the other lines of data.

 

I've messed around with various Copyfit and CopyfitLine configurations, but nothing has worked. Any advice/suggestions appreciated.

I would think you could simply select the first two paragraphs in the Text Editor, click the Paragraph button, then check the "Do not break on copyfit" box", click OK a couple times to apply that, then from the Frame Properties palette, click the Overflow button, and check "Adjust text to fit". No coding necessary.

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.

Guest
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...