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
  #11  
Old June 1st, 2016, 02:19 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: CopyFitting text on a business card

Quote:
Originally Posted by ScottHillock View Post
The v_field is a variable array. So it should only include values separated by a comma. The concatenation with the + is not needed, as that is handled later on.
So I would change it to:
Code:
var FirstLast = Field('First Name') + " " + Field('Last Name ') + ", ";
var v_field = [FirstLast, Field('Credentials') ].filter(String);
This way we can modify the FirstLast later if needed, while still using the rest of the code.
Doing this pretty much defeats the purpose of the 'filter' method. Consider a situation where both fields ("First Name" and "Last Name") are empty:
Code:
var FirstLast = Field('First Name') + " " + Field('Last Name ') + ", "; // FirstLast = " , "
var v_field = [FirstLast, Field('Credentials') ].filter(String); // v_field = [" , ", Field('Credentials')]
A more appropriate way to handle that is:
Code:
var FirstLast = Field('First Name') + ' ' + Field('Last Name');   // FirstLast = ' '
if (FirstLast = Trim(FirstLast))                                            
  FirstLast += ', ';

var v_field = [ FirstLast, Field('Credentials') ].filter(String); // v_field = [ Field('Credentials') ]
Or:
Code:
var v_field = [[Field('First Name'),Field('Last Name')].filter(String).join(' '), Field('Credentials')].filter(String).join(', '); // v_field = [ Field('Credentials') ]
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #12  
Old June 2nd, 2016, 07:06 AM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Default Re: CopyFitting text on a business card

Scott, I made the change and I still get the <f name="Arial"><newsize="12">FirstLast, Credentials

Credentials are rolling to a third line.

I have to be missing something!
Reply With Quote
  #13  
Old June 2nd, 2016, 09:18 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: CopyFitting text on a business card

Quote:
Originally Posted by TroyM68 View Post
Scott, I made the change and I still get the <f name="Arial"><newsize="12">FirstLast, Credentials
Are the literal tags showing in the text frame when you preview/compose? If so, there's a pretty good chance that you didn't check the "Treat returned strings as tagged text" checkbox at the top of the rule editor. Checking that box will cause FP to actually interpret those tags and apply the font and size to your text rather than print them.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #14  
Old June 2nd, 2016, 09:31 AM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Default Re: CopyFitting text on a business card

The text frame is named "name"

The rule is named "name" in that text field.

I am still getting the error:
Builtins.js line 3316 ERROR: in FindFrame(), No frame specified.

Also... Without this working... All the text font size reduces (ex: from 11pt to 6pt) Font size needs to remain at 11pt. Just the spacing between characters needs to adjust from no more then 100% down to no less then 85% of normal spacing. This may be because the OnCopyFit rule isn't working???

Name Rule.JPG

OnCopyFit.JPG

Error.JPG

TextFrame.JPG
Reply With Quote
  #15  
Old June 6th, 2016, 06:02 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,359
Default Re: CopyFitting text on a business card

You don't actually have to do all of this in the OnCopyfit callback rule, but if you do, then you want to write the rule like this, with your actual frame name on the first line:
Code:
if (FusionPro.Composition.CurrentFlow.name == "Name of frame with custom copyfitting")
{
    // Custom copyfitting logic here.
    return;
}
//else
// default copyfitting

if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
    ReportWarning("Could not copyfit text in flow " + 
                  FusionPro.Composition.CurrentFlow.name);
__________________
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
  #16  
Old June 7th, 2016, 12:21 PM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Thumbs up Re: CopyFitting text on a business card

Gentlemen,
I finally got this rule working thanks to all of you!
I really appreciate all of your help and advice on this one!!!
Reply With Quote
  #17  
Old June 28th, 2016, 03:18 PM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Default Re: CopyFitting text on a business card

Ran into a glitch...
This rule works great until the credentials field is left blank (it's not a required field). When the credentials field is blank... the return is:
First Last, (It returns a comma)

When the credentials are present the return is:
First Last, Credential (exactly as it should be)

How would I modify the rule to address this issue? Only use a "," if the credentials field is not empty?

Thanks again!
Reply With Quote
Reply

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 09:21 AM.


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