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 8th, 2015, 01:39 PM
jwhittaker jwhittaker is offline
Senior Contributor
 
Join Date: Feb 2009
Location: San Diego
Posts: 165
Default If copyfit then return error message

I have a 2 sided flyer with multiple text boxes with multiple text fields using different size of fonts and different number of fields. The customer that doesn't want to copyfit any text but wants to return red text saying "You have entered too much text" in that specific text box. Since there are several text fields with different fonts and sizes in each text box, I can’t really use the calculate text width because of all the different fields, fonts, and sizes. I have named all the text boxes and text1, text2, text3, etc.
My logic would be if textbox “text1” has to copyfit return, in red, "You have entered too much text"
else return whatever they entered. I just can’t figure out the syntax

I was thinking of changing the 25 and 400 to 100 in the copyfit rule but I don’t know how to select the textbox that has too much text and change the text to something else.

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))
ReportWarning("Could not copyfit text in flow " +
FusionPro.Composition.CurrentFlow.name);
__________________
FusionPro VDP Creator 10.0.26 | MacOS 10.13.4 | Acrobat DC
Reply With Quote
  #2  
Old October 8th, 2015, 02:59 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: If copyfit then return error message

Probably the easiest thing you could do (since they don't want to copy fit at all) would be to replace the contents of your "OnCopyfit" rule with this:
Code:
with (FusionPro.Composition.CurrentFlow) 
    if (!fits) content = '<para><span color="Red">' + 
            'You entered too much text.</span></para>';
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old October 8th, 2015, 03:05 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,549
Default Re: If copyfit then return error message

Try searching this forum for "copyfit error message". Two of the threads it returns are:
http://forums.pti.com/showthread.php?t=3165
http://forums.pti.com/showthread.php?t=2276

Both of those other threads basically have this answer to your question:
Code:
if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))
{
    ReportWarning("Text does not fit in flow " + 
                  FusionPro.Composition.CurrentFlow.name);
    FusionPro.Composition.CurrentFlow.content = '<para><color name="Red">TEXT DOES NOT FIT IN THIS FRAME!</para>';
}
__________________
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
  #4  
Old October 8th, 2015, 03:14 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,549
Default Re: If copyfit then return error message

Quote:
Originally Posted by step View Post
Probably the easiest thing you could do (since they don't want to copy fit at all) would be to replace the contents of your "OnCopyfit" rule with this:
Code:
with (FusionPro.Composition.CurrentFlow) 
    if (!fits) content = '<para><span color="Red">' + 
            'You entered too much text.</span></para>';
Ooh, that's a nice concise answer, and very clever! It's true that you don't actually need to call the Copyfit function.

I like the use of "with" there, although I try not to use it as Mozilla recommends against it, and it won't work in ECMAScript "strict mode". This is slightly less concise but more conformant:
Code:
var cf = FusionPro.Composition.CurrentFlow;
if (!cf.fits)
    cf.content = '<para><span color="Red">' + 
            'You entered too much text.</span></para>';
__________________
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 8th, 2015, 03:35 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: If copyfit then return error message

Quote:
Originally Posted by Dan Korn View Post
I like the use of "with" there, although I try not to use it as Mozilla recommends against it, and it won't work in ECMAScript "strict mode". This is slightly less concise but more conformant:
Code:
var cf = FusionPro.Composition.CurrentFlow;
if (!cf.fits)
    cf.content = '<para><span color="Red">' + 
            'You entered too much text.</span></para>';
Haha! Dan, originally the code I wrote for jwhittaker was exactly what you've posted above – down to the variable name. But, I'd previously read that page about "with" and revised my solution to get your opinion on it/how it would work within FusionPro. It just seems like it would be such a handy shorthand for all of the properties of the FusionPro object that I find myself typing so frequently. I had not, however, come across "strict mode" so I'll have to read into that page you posted here. Thank you for that.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old October 8th, 2015, 05:58 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,549
Default Re: If copyfit then return error message

Quote:
Originally Posted by step View Post
Haha! Dan, originally the code I wrote for jwhittaker was exactly what you've posted above – down to the variable name. But, I'd previously read that page about "with" and revised my solution to get your opinion on it/how it would work within FusionPro.
I guess I took the bait. Although I do like talking about JavaScript, so you have me pegged!
Quote:
Originally Posted by step View Post
It just seems like it would be such a handy shorthand for all of the properties of the FusionPro object that I find myself typing so frequently.
Well, this is getting off the original topic, but yes, the "with" statement can indeed be a handy shorthand. But there are some potential downsides in terms of possible ambiguities, as that MDN page notes in the Ambiguity contra section. It's also deprecated, which means that it may not work at all in a future version of JavaScript, or it may be disallowed under certain conditions such as "strict mode." Speaking of which...
Quote:
Originally Posted by step View Post
I had not, however, come across "strict mode" so I'll have to read into that page you posted here. Thank you for that.
Okay, but keep in mind that "strict mode" is a feature specific to ECMAScript 5, which is a later version than the JavaScript 1.7 which is currently embedded into FusionPro.

Further into the future, ECMAScript 6 introduces some other cool things like "let", which can help to better define the scope of variables and reduce ambiguity. There are neat features in other versions of JavaScript/ECMAScript as well, including JavaScript 1.8. Someday I hope to be able to bring in one of these newer versions to FusionPro, to be able to take advantage of some of the newer language features, but for now, it's JavaScript 1.7. So while I encourage you to look at newer versions of JavaScript/ECMAScript and even try them out in web pages and online tutorials and other such contexts, please be aware that the newer language features won't all work in FusionPro (though some new methods have polyfill you can add to use them in older versions).
__________________
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 October 9th, 2015, 06:37 AM
jwhittaker jwhittaker is offline
Senior Contributor
 
Join Date: Feb 2009
Location: San Diego
Posts: 165
Default Re: If copyfit then return error message

Step and Dan
Thank you so much for your help I really appreciate it. I love how there is always different ways of doing things.

Dan
I was close but I had everything in this except the <para> part of the last line.

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72))) { ReportWarning("Text does not fit in flow " + FusionPro.Composition.CurrentFlow.name); FusionPro.Composition.CurrentFlow.content = '<para><color name="Red">TEXT DOES NOT FIT IN THIS FRAME!</para>'; }
Thanks again!!!
__________________
FusionPro VDP Creator 10.0.26 | MacOS 10.13.4 | Acrobat DC
Reply With Quote
  #8  
Old October 9th, 2015, 07:50 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: If copyfit then return error message

Quote:
Originally Posted by Dan Korn View Post
I guess I took the bait. Although I do like talking about JavaScript, so you have me pegged!
Don't worry, when I devise a way to work a mention of (what looks to be) a very tall bicycle into one of my posts I will because I'm sure there's a conversation there.

Anyway, I won't derail the topic any further, just wanted to thank you for sharing this information with me and the rest of the community.

Quote:
Originally Posted by jwhittaker View Post
I was close but I had everything in this except the <para> part of the last line.
You were! All FusionPro text flows are wrapped with "para" tags so if you're replacing the content of one, you have to make sure you add those tags back in order for the text to display.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
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 03:45 AM.


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