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, 12:20 PM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 38
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, 08:39 AM
TroyM68
This message has been deleted by TroyM68. Reason: Creating a new topic
  #12  
Old May 26th, 2016, 10: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,592
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, 12:43 PM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 35
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, 06: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, 09: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,592
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
  #16  
Old February 11th, 2021, 11:54 AM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 75
Default Re: A better CopyfitLine

Dan,
I've just starting using this function in a rule for a address block. Works so much faster than the other method. The rule works splendidly. However I'm getting copy fit errors when I compose my pdf even tho the output is correct. Is this the normal behavior?

Code:
var Var1 = Field("FirstName") + " " +Field("LastName");
var Var2 = Field("Company");
var Var3 = Field("Address");
var Var4 = Field("Address2");
var Var5 = Field("City") + ", " + Field("State") + " " + Field("Zip");
var Var6;

function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand)
  {
    var tm = new FusionProTextMeasure;
    tm.CalculateTextExtent(line);
    if (tm.messages)
      ReportError("CopyfitMagnifyLine: " + tm.messages);
 
    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>";
  }
  
  
  Var6 = CopyfitLineWithMagnifyTag('<f name="Percanthen">' + '<z newsize=30>' + Var1, 234, false) + "<p>" +
            CopyfitLineWithMagnifyTag('<f name="Percanthen">' + '<z newsize=30>' + Var2, 234, false) + "<p>" +
            CopyfitLineWithMagnifyTag('<f name="Percanthen">' + '<z newsize=30>' + Var3, 234, false) + "<p>" + 
            CopyfitLineWithMagnifyTag('<f name="Percanthen">' + '<z newsize=30>' + Var4, 234, false) + "<p>" + 
            CopyfitLineWithMagnifyTag('<f name="Percanthen">' + '<z newsize=30>' + Var5, 234, false);
  
  return Var6;

FP 11.2.1

Acrobat
Architecture: x86_64
Build: 20.13.20074.411690
AGM: 4.30.104
CoolType: 5.14.5
JP2K: 1.2.2.46820
Reply With Quote
  #17  
Old February 11th, 2021, 12:03 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,592
Default Re: A better CopyfitLine

Quote:
Originally Posted by ThePorge View Post
I'm getting copy fit errors
What errors specifically?
__________________
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
  #18  
Old February 11th, 2021, 12:26 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 75
Default Re: A better CopyfitLine

Every record has these errors.

Quote:
Job started 13:09:40 - 1613066980.
Creator: FusionPro(R) VDP Creator 11.2.1
Computer Name:
Current working folder: /Applications/PTI/FusionPro
Temporary files folder: /var/folders/x4/mjdwd7nj7hv8phtj8_ljm3mr0000gn/T/
Template File: /Volumes/Mac_Jobs/140911_GSG/VarableWork/140911_GSG-EnvFPExport Test.dif
Input File: /Volumes/Mac_Jobs/140911_GSG/VarableWork/Links/140911_ListTest.csv
Job Config File: /private/var/folders/x4/mjdwd7nj7hv8phtj8_ljm3mr0000gn/T/140911_GSG-Env-Test.cfg
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
Composing record #1, input record 1
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
Composing record #2, input record 2
Reply With Quote
  #19  
Old February 11th, 2021, 12:30 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 75
Default Re: A better CopyfitLine

Just the text won't fit errors even tho it does.
Quote:
Job started 13:09:40 - 1613066980.
Creator: FusionPro(R) VDP Creator 11.2.1
Computer Name:
Current working folder: /Applications/PTI/FusionPro
Temporary files folder: /var/folders/x4/mjdwd7nj7hv8phtj8_ljm3mr0000gn/T/
Template File: /Volumes/Mac_Jobs/140911_GSG/VarableWork/140911_GSG-EnvFPExport Test.dif
Input File: /Volumes/Mac_Jobs/140911_GSG/VarableWork/Links/140911_ListTest.csv
Job Config File: /private/var/folders/x4/mjdwd7nj7hv8phtj8_ljm3mr0000gn/T/140911_GSG-Env-Test.cfg
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
Composing record #1, input record 1
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>. Text is truncated.
Text does not fit in the last frame on page 0 at (0 in, 0 in).
Composing record #2, input record 2
Reply With Quote
  #20  
Old February 11th, 2021, 12:40 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,592
Default Re: A better CopyfitLine

Okay, well, what does fit? You probably either have the wrong frame width, or maybe the frame simply isn't big enough vertically. I'd have to see the job files to reproduce the problem and analyze it.
__________________
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)});

Last edited by Dan Korn; February 11th, 2021 at 12:57 PM..
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 04:09 AM.


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