Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 15th, 2019, 01:36 PM
blyons blyons is offline
Forum n00b
 
Join Date: Mar 2016
Posts: 6
Default OnCopyfit Rule: problem

Greetings all,
We are stumped on a copyfit issue, and would appreciate any help you may be able to give. Here is the rule and the issue below. thanks so much in advance for any help!!!!
OnCopyfit Rule:

Rule("OnCopyfit")

if (FusionPro.Composition.CurrentFlow.name == "Event");
MagnifyAttributes("Event", 0, 400, 6, 0);

if (FusionPro.Composition.CurrentFlow.name == "Special Message");
MagnifyAttributes("Special Message", 25, 400, 6, 72);

ReportWarning("Could not copyfit text in flow " +
FusionPro.Composition.CurrentFlow.name);


In the Text frame “Event” under paragraph formatting, I have the box for “Do not break on copyfit” checked and under Overflow Options I have Adjust text to fit checked along with Allow text to expand to fill.
So ideally, I would like whatever the customer types in to the box to fill the box and stay on one line However, right now it is breaking into two lines and discarding the text that doesn’t fit.

screen shot attached
Attached Images
File Type: jpg copyfit.jpg (39.2 KB, 6 views)
Reply With Quote
  #2  
Old October 15th, 2019, 06:28 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,359
Default Re: OnCopyfit Rule: problem

Well, you're kind on the right track. The FusionPro User Guide has a section titled "Applying different copyfitting attributes to separate frames." Following the example there, you could do something like this:
Code:
var magnifyAttrs = new MagnifyAttributes("text", 25, 400, 6, 72); // default magnification settings

if (FusionPro.Composition.CurrentFlow.name == "Event")
    magnifyAttrs = new MagnifyAttributes("text", 0, 400, 6, 0);

if (!Copyfit(magnifyAttrs))
    ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name);
Where you instantiate a new instance of an object of type MagnifyAttributes for each particular frame. (Note that the first parameter to the MagnifyAttributes constructor, as documented in the FusionPro Rules Guide, as well as in the Objects tab of the Building Blocks, is not a frame name, but rather a type, or method, of magnification, which can be one of: "text", "textheight", "textwidth", "leading", or "tracking", to control exactly how the text should be magnified [squeezed] to fit.)

However, all that said, that's not going to work for the particular case you're in, which is basically what I would call single-line copyfitting, which is different from what that OnCopyfit rule controls, which is I call full-flow copyfitting.

Instead of full-flow copyfitting for your single line, you want to use the CopyfitLine function, or better yet, my improved version of it, in a regular text rule, giving it the content (text) for the line, and then using that rule in the Text Editor. With recent versions of FusionPro, you can make this work in any text frame, without having to hard-code either the frame name or the width of the frame into the rule. You do still need to hard-code the initial font and point size though.

It's hard to give you exactly the right rule without having the template, but something like this should work:
Code:
var lineText = TaggedDataField("Event Name");
var initialFont = "Arial";
var initialPointSize = 30;

if (FusionPro.inValidation)
    return lineText;

var content = '<f name="' + initialFont + '"><z newsize="' + initialPointSize + '">' + lineText;
var frameWidth = FusionPro.Composition.CurrentFlow.GetFrame().GetSettableTextWidth();
return CopyfitLineWithMagnifyTag(content, frameWidth);

function CopyfitLineWithMagnifyTag(line, width, AllowToExpand)
{
    var tm = new FusionProTextMeasure;
    tm.CalculateTextExtent(line);
    if (tm.messages)
        ReportError("CopyfitMagnifyLine: " + tm.messages);

    if (tm.textWidth < width && !AllowToExpand)
        return line;

    var factor = Round(width / tm.textWidth * 100, 0) - 1;
    return "<magnify type=text factor=" + factor + ">" + line + "</magnify>";
}
Note that this goes into a regular old Text rule (NOT the OnCopyfitCallback), and you need to check both the "Re-evaluate this rule for every text flow" and "Treat returned strings as tagged text" boxes.

The only other things you need to do are modify the first three lines of the rule to specify your data field and the initial font and size, then replace the variable calling out the data field in the Text Editor to call this rule instead.
__________________
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
  #3  
Old October 16th, 2019, 08:28 AM
blyons blyons is offline
Forum n00b
 
Join Date: Mar 2016
Posts: 6
Default Re: OnCopyfit Rule: problem

Thanks Dan, I replaced my rule with your suggested rule and when I validate it, it returns Expression Ok and the Return Value shows the correct message however the text box still breaks into two lines. Also, I might be missing something here but now when I compose the template I get an error message that reads:
Composing record #1, input record 1
uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function
uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function
Job ended 09:13:54 - 1571231634.

See Screen Shot
Attached Images
File Type: jpg 10-16.jpg (257.7 KB, 2 views)
Reply With Quote
  #4  
Old October 16th, 2019, 10:10 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: OnCopyfit Rule: problem

Quote:
Originally Posted by blyons View Post
Also, I might be missing something here but now when I compose the template I get an error message that reads:[/FONT][/COLOR][/SIZE]
Composing record #1, input record 1
uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function
uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function
Okay, thanks for posting the picture with the log file. I can see that you're using FusionPro 10.0. This is why I ask you to please specify the versions of FusionPro, Acrobat, and your operating system, because the answer can be dependent on those, and I'm bad at guessing. In the absence of a specific version, my answers are always going to be for the latest version (currently FP 11), which is what I'm running.

For FP 10.0, you can change line 9 of the rule to this:
Code:
var frameWidth = FindTextFrame(FusionPro.Composition.CurrentFlow.name).GetSettableTextWidth();
__________________
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
  #5  
Old October 17th, 2019, 09:58 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: OnCopyfit Rule: problem

Let me clarify that the FusionPro.Composition.CurrentFlow.GetFrame function is NOT new in FP 11. It was added in FusionPro 10.1. You don’t have it because you're running 10.0. You can upgrade for free to 10.1.
__________________
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
  #6  
Old November 7th, 2019, 06:50 AM
blyons blyons is offline
Forum n00b
 
Join Date: Mar 2016
Posts: 6
Default Re: OnCopyfit Rule: problem

Dan many thanks… That worked like a charm! My apologies for not seeing your recommendation regarding the inclusion of the FusionPro versioning. I will make a note of that and be sure to include my versioning on any future posts.
Reply With Quote
Reply

Tags
copyfit, overflow, text frame

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 10:09 PM.


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