#1
|
|||
|
|||
![]()
So I was able to come up with a good rule for On Record Start for a Name/Title field, but then had to add in a condition for the address as well. It worked perfectly fine until I added the address portion & now it will only use the 'long page', even when the 'short page' is supposed to be used.
Is there something missing below? I've been racking my brain to figure out what is going on, but every time I validate, FusionPro returns 'Expressions Ok'. Thanks for the look. var name = Field("Name"); var title = Field("Title"); var nametitle = name + "," + title; if (nametitle.length <= 26){ FusionPro.Composition.SetBodyPageUsage("Short Name", true); FusionPro.Composition.SetBodyPageUsage("Long Name", false); } else{ FusionPro.Composition.SetBodyPageUsage("Short Name", false); FusionPro.Composition.SetBodyPageUsage("Long Name", true); }; var address = Rule("Format Address"); if (address.length <= 40){ FusionPro.Composition.SetBodyPageUsage("Short Name", true); FusionPro.Composition.SetBodyPageUsage("Long Name", false); } else{ FusionPro.Composition.SetBodyPageUsage("Short Name", false); FusionPro.Composition.SetBodyPageUsage("Long Name", true); } |
#2
|
||||
|
||||
![]()
It seems to me that this part of the rule has absolutely no effect:
Quote:
Quote:
Although, in 99 out of 100 cases like this, you can usually implement some other way of accomplishing the results you need without creating entirely new sets of pages for variable text of different lengths. The most common way to resolve something like this is via copyfitting, either full-flow copyfitting (by checking the "Adjust text to fit" box on the Overflow Options dialog), or per-line copyfitting (by using the CopyfitLine or similar text measurement in a rule. Other strategies including having multiple (sets of) frames and selectively suppressing them, resizing frames, and using tables. If I could see the job files, or at least the desired output, I might be able to offer a more specific suggestion. Also, the reason you get "Expressions OK" is because, well, the expressions are okay. If you want to return something from the rule just to see what's happening, you can certainly do that, but, as the message will then say, the return value will have no effect on the composition.
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#3
|
|||
|
|||
![]()
Dan,
Unfortunately I am not able to load the file or the zip right now. I will keep trying. As for the desired affect; If the name + title > 26 characters and/or the Address is > 40 characters, the initial page with graphic frames is to be forgone & the second page with no graphic frames is to be used (as it has larger text frames). This is due to the fact that fonts cannot be smaller than they already are (which is why I cannot use any sort of copy fitting or resizing rules). I don't know if this clears anything up for you |
#4
|
||||
|
||||
![]()
Okay, I think the key word in your description of the requirement is "OR".
Quote:
Code:
var address = Rule("Format Address"); var name = Field("Name"); var title = Field("Title"); var nametitle = name + "," + title; if (nametitle.length > 26 || address.length > 40) { FusionPro.Composition.SetBodyPageUsage("Short Name", false); FusionPro.Composition.SetBodyPageUsage("Long Name", true); return "using long names"; } else { FusionPro.Composition.SetBodyPageUsage("Short Name", true); FusionPro.Composition.SetBodyPageUsage("Long Name", false); return "using short names"; } Code:
var address = Rule("Format Address"); var nametitle = Field("Name") + "," + Field("Title"); var needLongText = (nametitle.length > 26 || address.length > 40); FusionPro.Composition.SetBodyPageUsage("Short Name", !needLongText); FusionPro.Composition.SetBodyPageUsage("Long Name", needLongText); return "using " + (needLongText ? "long" : "short") + " names";
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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; July 31st, 2017 at 02:44 PM.. Reason: fixed typo |
#5
|
|||
|
|||
![]()
OK the or was definitely confusing me. I am however getting a syntax error with both rules.
Line 6, (the first vertical bar is highlighted |) Syntax error: syntax error is what is read. This rule makes sense to use, but even after retyping it, I am still getting an error |
#6
|
||||
|
||||
![]() Quote:
Code:
if (nametitle.length > 26 || address.length > 40) Code:
var needLongText = (nametitle.length > 26 || address.length > 40);
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#7
|
|||
|
|||
![]()
Thanks Dan, I think that is working. I cannot preview or see anything in the composition file, but I believe that means that all is good!
|
#8
|
||||
|
||||
![]() Quote:
I will leave you with one other thing to consider: Counting the number of characters is a very poor way to determine whether text is going to fit into a particular frame. Unless you're using a monospaced font, some letters are wider than others. A name with a lot of W's and M's is going to take up a lot more space than a name with a lot of I's and L's, even with the same number of characters. For instance, in the default font on this forum: Quote:
Code:
var nametitle = Field("Name") + "," + Field("Title"); var address = Rule("Format Address"); var TM = new FusionProTextMeasure; TM.font = "Arial"; // <- font you're using TM.pointSize = 10; // <- text point size TM.CalculateTextExtent(nametitle); var nameFrame = FindTextFrame("Name"); // <- your frame name var nameTitleTooBig = TM.textWidth > nameFrame.GetSettableTextWidth(); TM.font = "Arial"; // <- font you're using TM.pointSize = 10; // <- text point size TM.CalculateTextExtent(address); var addressFrame = FindTextFrame("address"); // <- your frame name var addressTooBig = TM.textWidth > addressFrame.GetSettableTextWidth(); var needLongText = nameTitleTooBig || addressTooBig; FusionPro.Composition.SetBodyPageUsage("Short Name", !needLongText); FusionPro.Composition.SetBodyPageUsage("Long Name", needLongText); return "using " + (needLongText ? "long" : "short") + " names";
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#9
|
|||
|
|||
![]()
Dan, thanks for all the help. I was wondering though, how one would go about suppressing frames vs. suppressing pages. Obviously you would have multiple frames overlapping each other, but is there something in FusionPro (like an OnRecordStart rule) that does this? Or is it pure scripting?
|
#10
|
|||
|
|||
![]()
Look in the user manual for 'Modifying Frames During Composition'. This section will give you an overview of how to programmatically write (or add to ) a OnRecordStart rule to find and modify either a graphic or text frames properties. To find all the properties of a frame (of which suppress is one), consult the Rules system guide under the FusionProFrame Attributes section.
|
![]() |
Tags |
fusionpro, javascript, onrecordstart |
Thread Tools | Search this Thread |
Display Modes | |
|
|