|
#1
|
|||
|
|||
![]()
Hello all!
I am working with a bit of a pain customer. When I enter certain extended characters in the MCC Storefront it either switches them with greek symbols or switches them back to a standard char set (The character in question is this special apostrophe that their style guide requires). The support workaround for this is to type in the entity with a replace substring rule, but the way that they set it up is on an individual field basis, which on some templates can get quite long! So, my question is a two-fold question:
Code in question: Code:
//The end-user needs to enter in entity values to access special characters. However the following is necessary as MCC tries to "help" //in converting entities. The following replace substring will fix the "help" provided so that you can actually return the entity typed in. FusionPro.Composition.AddVariable("Date and Time Information",ReplaceSubstring(Field("Date and Time Information"),"&","&"),true); FusionPro.Composition.AddVariable("Event Information",ReplaceSubstring(Field("Event Information"),"&","&"),true); FusionPro.Composition.AddVariable("Direction 1 Information",ReplaceSubstring(Field("Direction 1 Information"),"&","&"),true); FusionPro.Composition.AddVariable("Direction 2 Information",ReplaceSubstring(Field("Direction 2 Information"),"&","&"),true); FusionPro.Composition.AddVariable("Direction 3 Information",ReplaceSubstring(Field("Direction 3 Information"),"&","&"),true); FusionPro.Composition.AddVariable("Direction 4 Information",ReplaceSubstring(Field("Direction 4 Information"),"&","&"),true); FusionPro.Composition.AddVariable("Date and Time Information",ReplaceSubstring(Field("Date and Time Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Event Information",ReplaceSubstring(Field("Event Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Direction 1 Information",ReplaceSubstring(Field("Direction 1 Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Direction 2 Information",ReplaceSubstring(Field("Direction 2 Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Direction 3 Information",ReplaceSubstring(Field("Direction 3 Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Direction 4 Information",ReplaceSubstring(Field("Direction 4 Information"),"&rsquor","’"),true); FusionPro.Composition.AddVariable("Date and Time Information",ReplaceSubstring(Field("Date and Time Information"),"'","’"),true); FusionPro.Composition.AddVariable("Event Information",ReplaceSubstring(Field("Event Information"),"'","’"),true); FusionPro.Composition.AddVariable("Direction 1 Information",ReplaceSubstring(Field("Direction 1 Information"),"'","’"),true); FusionPro.Composition.AddVariable("Direction 2 Information",ReplaceSubstring(Field("Direction 2 Information"),"'","’"),true); FusionPro.Composition.AddVariable("Direction 3 Information",ReplaceSubstring(Field("Direction 3 Information"),"'","’"),true); FusionPro.Composition.AddVariable("Direction 4 Information",ReplaceSubstring(Field("Direction 4 Information"),"'","’"),true); |
#2
|
||||
|
||||
![]()
I think this might work:
Code:
// An object of values to find as the keys, // and the string to replace them with as the value. var charMap = { // Find : Replace "&" : "&", "&rsquor" : "’", "'" : "’", } // Loop through all of the fields. for (var field in FusionPro.Fields) { // Loop through all of the find/replace values for current field. for (var find in charMap) { var replace = charMap[find]; FusionPro.Composition.AddVariable(field, ReplaceSubstring(Field(field), find, replace), true); } }
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#3
|
|||
|
|||
![]()
Thanks for the reply, in your code which of the values do I need to replace with names from my template, if any?
|
#4
|
||||
|
||||
![]() Quote:
Although, I think there's a way to fix at least part of the problem (entities such as "&" in the output) without doing that. I suspect that these "extended" characters are showing up correctly when the data fields are used directly in text frames in your job, and that the problem is related to when you're calling the Field function in rules. So if you replace the Field calls in your other rules with TaggedDataField, and possibly check the "Treat returned strings as tagged text" box in those rules as well, I think that will prevent the entities from appearing in your output. As for why MarcomCentral inserts "straight" quotes instead of "curly" quotes, that's a question for the MarcomCentral forum.
__________________
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; September 8th, 2017 at 06:30 PM.. |
#5
|
|||
|
|||
![]()
That's correct, this rule appears to be the perfect solution, but I'm not sure it is seaching the fields to replace characters as nothing is changing. Normally these quotes are used to specify an Alumni year and by using the class year as its own field it inserts the apostrophe fine (see below)
Code:
if (Field("Class Year") == "") return ""; else return ' ’'+Field("Class Year"); Code:
// An object of values to find as the keys, // and the string to replace them with as the value. var charMap = { // Find : Replace "’":"’", "’":"'", "¼":"¼", "½":"½", "¾":"¾", "—":"–", "—":"—", } // Loop through all of the fields. for (var field in FusionPro.Fields) { // Loop through all of the find/replace values for current field. for (var find in charMap) { var replace = charMap[find]; FusionPro.Composition.AddVariable(field, ReplaceSubstring(Field(field), find, replace), true); } } |
#6
|
||||
|
||||
![]() Quote:
__________________
Lance Wente Woolverton Printing Cedar Falls, IA 50613 800.670.7713 FusionPro Desktop 13.0.1 - Acrobat DC 2022 - OS X 12.6.1 Mac Studio M1 |
#7
|
|||
|
|||
![]()
Are you able to move the thread to the MarcomCentral forum or should I create new?
|
#8
|
|||||
|
|||||
![]() Quote:
Quote:
Quote:
Quote:
Quote:
The way you're telling FusionPro whether to treat the value as tagged is in that last parameter in the call to FusionPro.Composition.AddVariable. Setting it to true is equivalent to having a rule with the same name as the first parameter (the variable name) and checking that "Treat as tagged" box. Setting it to false is the same as leaving that box unchecked. You could create a new thread there just about the question about how MarcomCentral inserts the quotes into the data file it generates. This thread can be continued though.
__________________
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
|
||||
|
||||
![]()
Oh okay, thank you for attaching your collected template. I see what you're saying. Well this is kind of awkward. After I posted that whole missive about how "AddVariable" works, it turns out I don't know how it works.
![]() I think this will give you the results you're looking for, though: Redefine the "Field" function and do the find/replace within it so that calls to the "Field" function within rules return the desired value. Then in your OnRecordStart callback loop through all of the fields, and set their values to the result of the "Field" function which will perform the find/replace on fields inserted directly into text frames. JavaScript Globals: Code:
Field = function(str) { var res = FusionPro.Fields[str] || ''; // An object of values to find as the keys, and the string to replace them with as the value. var charMap = { // find : replace "first" : "FIRST", "last" : "LAST", } // Loop through all of the find/replace values for current field. for (var find in charMap) { var replace = charMap[find]; res = ReplaceSubstring(res, find, replace); } return res; } Code:
// Loop through all of the fields. for (var field in FusionPro.Fields) FusionPro.Composition.AddVariable(field, Field(field), true);
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|