Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 14th, 2009, 06:39 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Horizontal Scale to Copy Fit a Variable

I need to Copyfit a single field named Email by horizontal scale only. The Email field is in a text frame containing other variables, but the only variable that needs copyfit is Email. The point size is 8 and the leading is 10. I don't want the point size or leading to change. I don't want to use tracking, just horizontal scale. I don't want it to expand, only contract, if needed.

I'm having a difficult time finding a rule to accommodate this. Any help would be appreciated. Thanks!
Reply With Quote
  #2  
Old March 15th, 2009, 09:39 AM
azatko azatko is offline
Junior Community Member
 
Join Date: Dec 2008
Posts: 19
Default Re: Horizontal Scale to Copy Fit a Variable

Dave, the CopyfitQS.pdf guide contains a chapter named "Scenario – Copyfitting a line, or part of a line, of text". It seems, that might be what you are looking for.

A.
Reply With Quote
  #3  
Old March 15th, 2009, 07:14 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Horizontal Scale to Copy Fit a Variable

Thanks A. According to the document, it looks as if CopyfitLine will allow the field to stretch or stay as is, but not make the font narrower. I'm also confused about implementing it. Should I use it in a Text based rule or a Callback? (I suppose I could try and find out.)

I modified the built in OnCopyfit to use textwidth, but it applies it to the entire frame.

if (!Copyfit(new MagnifyAttributes("textwidth", 75, 100, 7, 8)))
ReportWarning("Could not copyfit text in flow " +
FusionPro.Composition.CurrentFlow.name);

-Dave
Reply With Quote
  #4  
Old March 16th, 2009, 12:57 AM
azatko azatko is offline
Junior Community Member
 
Join Date: Dec 2008
Posts: 19
Default Re: Horizontal Scale to Copy Fit a Variable

Using the link below you can download (not sure how long will the free service keep the file but I expect at least a month) a sample template that shows the CopyfitLine function in action.

http://www.ziddu.com/download/3883242/copyfit.zip.html

Please note 2 things:

1) the archive does not include the font used in the template - Palatino Linotype. You might want to change the font name in the rule to match the font you want to use.
2) the rule is defined to scale the font size, but you can set the last attribute of the function to "true" and the width of the text string will be adjusted instead of the size.
Reply With Quote
  #5  
Old March 16th, 2009, 05:26 AM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 240
Default Re: Horizontal Scale to Copy Fit a Variable

David,

Here's a function that has worked for me in the past. I haven't used is very often though.
Code:
function CopyfitLineWtextwidth(staticpart, dynpart, font, staticsize, size, minimumwidth, justwidth)
{
var tm = new FusionProTextMeasure;
tm.maxWidth = -1;
var newsize, retcode;
basetags = "<f name=\"" + font + "\"><setwidth newsize=" + size + ">" + staticpart;
newsize = staticsize;
do
{
tags = basetags;
tags += (justwidth) ? "<setwidth " : "<z ";
tags += "newsize=" + newsize + ">" + dynpart;
retcode = tm.CalculateTextExtent(tags);
if (tm.textWidth > size * 100) 
newsize -= 0.1;
} while (newsize > minimumwidth && tm.textWidth > minimumwidth*100 && retcode == 0);
return tags; // + " " + tm.textWidth + " " + width*100;
} 
CopyfitLine.builtin = true;
Good Luck.
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #6  
Old March 16th, 2009, 09:17 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,342
Default Re: Horizontal Scale to Copy Fit a Variable

You call the CopyfitLine function from a regular text rule, not from a Callback rule. You need to supply the effective width of the text frame; if you're using FP 6.0 you can use the new FindTextFrame and FusionProTextFrame.GetSettableTextWidth functions to get the width automatically, otherwise, you'll have to hard-code it.

You can also try this:
http://forums.printable.com/showthread.php?t=84
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old March 18th, 2009, 10:14 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Horizontal Scale to Copy Fit a Variable

Thanks to everyone for the info. Got it working and learned a lot about copyfit in the process.
Reply With Quote
  #8  
Old June 29th, 2009, 07:52 AM
Allegra Allegra is offline
Junior Community Member
 
Join Date: Jun 2009
Posts: 14
Default Re: Horizontal Scale to Copy Fit a Variable

Hello David,
I am not very experienced with Javascript, and I am trying to do pretty much exactly what you needed. I need to contract a whole line of versioned address information, but only if it is to long to fit in one line. It is the only text in the frame, and so far i only know how to expand it. Would you be able to show/send me the final rule you used to contract your feild?

Thanks,
Meir Galimidi
Reply With Quote
  #9  
Old June 30th, 2009, 07:00 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Horizontal Scale to Copy Fit a Variable

Hi Meir,

azatco, DSweet, and Dan Korn are better qualified to answer your question here. My client opted to copyfit the entire text frame the same way, not just the email address, so it was fairly easy. We were able to modify the built-in copyfit rule to work for our template.

if (!Copyfit(new MagnifyAttributes("textwidth", 75, 100, 7, 8)))
ReportWarning("Could not copyfit text in flow " +
FusionPro.Composition.CurrentFlow.name);

Whereas, "text" was changed to "textwidth", minimum width was set to 75%, maximum width was set to 100%, minimum point size was set to 7 pt, and maximum point size was set to 8 pt. (The client opted for the original rule posted above because, "everything looked better".)

You can set a particular field to do the same. For example, email.

I suggest reading "Copfitting in FusionPro" (CopyfitQS.pdf). Start around page 24 for email options. Download azatco's example mentioned above. (It is still available.)

You should also take a look at DSweet's and Dan Korn's post above.

Thanks,
David Miller

Last edited by David Miller; June 30th, 2009 at 07:13 PM.. Reason: Wasn't finished yet.
Reply With Quote
Reply

Tags
copyfit, horizontal scale, variables

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 08:07 PM.


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