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 August 19th, 2015, 11:20 AM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 34
Default Re: A better CopyfitLine

Dan,
Sorry; I meant text frame, not text field. The code you posted using the FindTextFrame and GetSettableTextWidth() functions works perfectly!!
Thanks.
Reply With Quote
Old May 26th, 2016, 07:39 AM
TroyM68
This message has been deleted by TroyM68. Reason: Creating a new topic
  #12  
Old May 26th, 2016, 09:20 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,305
Default Re: A better CopyfitLine

Quote:
Originally Posted by TroyM68 View Post
They would like the field "Credentials" to be able to fill the remaining space in the top line, roll to the second line and have the ability to fill the entire second line. They want to be able to copyfit the text and spacing Width the field "Credentials" for the first two lines to a given %. Else return something like "Credential Do Not Fit".
Well, first of all, a new thread should be used for a new question. And this isn't really supposed to be just the "Ask Dan" forum.

Anyway, I'm not sure I understand the requirements. Under what specific criteria do the Credentials not fit? If First Name, Last Name, and Credentials/Certifications would fill more than two lines after shrinking a certain amount? Maybe some examples of what you expect to see with different data would be helpful. (Also, do you mean Credentials or Certifications?)
__________________
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
  #13  
Old May 26th, 2016, 11:43 AM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 26
Default Re: A better CopyfitLine

Sorry Dan, I thought this was similar to the thread. I will create a new post with more detail. Thanks!
Reply With Quote
  #14  
Old September 27th, 2016, 05:53 PM
sdthedawson sdthedawson is offline
Forum n00b
 
Join Date: Sep 2015
Posts: 1
Default Re: A better CopyfitLine

I love and use this function all the time! However it has issues with specific characters being used like &, <, >. Here’s a simple fix for it that. It escapes the codes to HTML runs the copy fit calculations and then un-escapes the codes back. I am unable to fully test if the magnify factor is affected due to the HTML characters being more characters. Either way its worked well for me!

Code:
function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand)
{
    var escapeCode = [
        [/\&/g, "&", "&amp;"],
        [/\</g, "<", "&lt;"],
        [/\>/g, ">", "&gt;"],
        [/\¢/g, "¢", "&cent;"],
        [/\£/g, "£", "&pound;"],
        [/\¥/g, "¥", "&yen;"],
        [/\€/g, "?", "&euro;"],
        [/\©/g, "©", "&copy;"],
        [/\®/g, "®", "&reg;"]
    ];

    //Escape to HTML code for copyFit
    for(i=0;i<escapeCode.length;i++){
        line = line.replace(escapeCode[i][0], escapeCode[i][2]);
    }
    
    var tm = new FusionProTextMeasure;
    tm.CalculateTextExtent(line);
    if (tm.messages){
      ReportError("CopyfitMagnifyLine: " + tm.messages);
    }
	
    //Unescape HTML codes
    for(i=0;i<escapeCode.length;i++){
        line = line.replace(escapeCode[i][2], escapeCode[i][1]);
    }

    if (tm.textWidth < widthInPoints*100 && !AllowToExpand){
      return line;
    }

    var factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1;
    return "<magnify type=setwidth factor=" + factor + ">" +
           line + "</magnify>";
}
Reply With Quote
  #15  
Old September 29th, 2016, 08:09 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,305
Default Re: A better CopyfitLine

Quote:
Originally Posted by sdthedawson View Post
I love and use this function all the time! However it has issues with specific characters being used like &, <, >. Here’s a simple fix for it that. It escapes the codes to HTML runs the copy fit calculations and then un-escapes the codes back. I am unable to fully test if the magnify factor is affected due to the HTML characters being more characters. Either way its worked well for me!
You shouldn't need to do any of that as long as you pass tagged markup to the function in the first place, either by calling TaggedTextFromRaw or TaggedDataField, and set the rule to return tagged markup, as explained in previous posts in this thread.
__________________
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
Reply

Tags
javascript, rules

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 12:34 PM.


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