step Posted August 16, 2016 Posted August 16, 2016 The only other thing I'm struggling on with this is trying to get something like this to work: '<<actual>>++': Rule("ActualR1"), '<<actual>>+': Rule("ActualR2"), '<<actual>>†': Rule("ActualR3"), '<<actual>>‡': Rule("ActualR4"), It's kind of difficult to say what's going on from just those 4 lines of code. I will remind you, though: Keep in mind that both plus signs and carets have special meanings in regular expressions so they must be escaped. The reason being is the "actual" field in the letter is 36 point, so the superscript doesn't go up high enough. I made 4 rules applying each occurrence of the character options at the appropriate superscript height. It won't recognize this as text within the frame though. Thank You! Again, I'm not really sure what you're saying. You can adjust the size and offset of the superscripting globally by adjusting your "Paragraph" settings. But after creating 4 rules and a complicated regexp, wouldn't it be worth asking yourself "is this really any easier than inserting the placeholders with the fields from the text editor?" Quote
VernF88 Posted August 16, 2016 Posted August 16, 2016 (edited) It's kind of difficult to say what's going on from just those 4 lines of code. I will remind you, though: Again, I'm not really sure what you're saying. You can adjust the size and offset of the superscripting globally by adjusting your "Paragraph" settings. But after creating 4 rules and a complicated regexp, wouldn't it be worth asking yourself "is this really any easier than inserting the placeholders with the fields from the text editor?" I uploaded an image for my meaning. Next to the large "$13,555" are the superscript characters I'm wanting to correct with the rule. As you'll see in the next paragraph down next to the "$1,500 Bonus Cash" the "+" character is the correct height. So the global setting cannot be modified to fix the issue. The code I have in the rule's correct the height and insure they aren't bold: return FormatNumber("$#,###", Field("Actual").replace(/[^\d\.-]/g,'')) + "<p br=false superoffset=175 superratio=30><span bold=false><superscript>++</superscript></span bold=false><p br=false superoffset=58 superratio=50>" That will produce the correct height "++". Literally whats in the text frame is "<<actual>>++" so I input: var chars = { // Find: Replace: '\\^': '<superscript>^</superscript>', '\\+': '<superscript>+</superscript>', '†': '<superscript>†</superscript>', '‡': '<superscript>‡</superscript>', '<<first>>': Field("First Name"), '<<last>>': Field("Last Name"), '<<year>>': Field("Year"), '<<make>>': Field("Make"), '<<model>>': Field("Model"), '<<model2>>': Field("Model2"), '<<model3>>': Field("Model3"), '<<V1>>': Field("V1"), '<<V2>>': Field("V2"), ' <<V3>>': Rule("V3R"), ' <<V4>>': Rule("V4R"), '<<V5>>': Field("V5"), '<<v1>>': Field("V1"), '<<v2>>': Field("V2"), ' <<v3>>': Rule("V3R"), ' <<v4>>': Rule("V4R"), '<<v5>>': Field("V5"), '<<more>>': Rule("MoreR"), [color="Red"]'<<actual>>\\++': Rule("ActualR1"), '<<actual>>\\+': Rule("ActualR2"), '<<actual>>†': Rule("ActualR3"), '<<actual>>‡': Rule("ActualR4"),[/color] '<<actual>>': Rule("ActualR"), '<<winno>>': Field("WinNo"), } var text = FindTextFrame('FullBody').content .replace(/<variable name="([^"]*)">/g, function(s,p) { return FieldOrRule(p); }) .replace(/&([lg])t;/g, function(s,p) { return p == 'l' ? '<' : '>'; }); for (var i in chars) text = text.replace(new RegExp(i, 'g'), chars[i]); FindTextFrame('FullBody').content = text; I realize I could highlight and replace the space holder but that's literally the last thing left in the letter that isn't automated. I appreciate all your help! Edited August 16, 2016 by VernF88 Quote
VernF88 Posted August 17, 2016 Posted August 17, 2016 I uploaded an image for my meaning. Next to the large "$13,555" are the superscript characters I'm wanting to correct with the rule. As you'll see in the next paragraph down next to the "$1,500 Bonus Cash" the "+" character is the correct height. So the global setting cannot be modified to fix the issue. The code I have in the rule's correct the height and insure they aren't bold: return FormatNumber("$#,###", Field("Actual").replace(/[^\d\.-]/g,'')) + "<p br=false superoffset=175 superratio=30><span bold=false><superscript>++</superscript></span bold=false><p br=false superoffset=58 superratio=50>" That will produce the correct height "++". Literally whats in the text frame is "<<actual>>++" so I input: var chars = { // Find: Replace: '\\^': '<superscript>^</superscript>', '\\+': '<superscript>+</superscript>', '†': '<superscript>†</superscript>', '‡': '<superscript>‡</superscript>', '<<first>>': Field("First Name"), '<<last>>': Field("Last Name"), '<<year>>': Field("Year"), '<<make>>': Field("Make"), '<<model>>': Field("Model"), '<<model2>>': Field("Model2"), '<<model3>>': Field("Model3"), '<<V1>>': Field("V1"), '<<V2>>': Field("V2"), ' <<V3>>': Rule("V3R"), ' <<V4>>': Rule("V4R"), '<<V5>>': Field("V5"), '<<v1>>': Field("V1"), '<<v2>>': Field("V2"), ' <<v3>>': Rule("V3R"), ' <<v4>>': Rule("V4R"), '<<v5>>': Field("V5"), '<<more>>': Rule("MoreR"), [color="Red"]'<<actual>>\\++': Rule("ActualR1"), '<<actual>>\\+': Rule("ActualR2"), '<<actual>>†': Rule("ActualR3"), '<<actual>>‡': Rule("ActualR4"),[/color] '<<actual>>': Rule("ActualR"), '<<winno>>': Field("WinNo"), } var text = FindTextFrame('FullBody').content .replace(/<variable name="([^"]*)">/g, function(s,p) { return FieldOrRule(p); }) .replace(/&([lg])t;/g, function(s,p) { return p == 'l' ? '<' : '>'; }); for (var i in chars) text = text.replace(new RegExp(i, 'g'), chars[i]); FindTextFrame('FullBody').content = text; I realize I could highlight and replace the space holder but that's literally the last thing left in the letter that isn't automated. I appreciate all your help! Sorry my photo was too large I just now noticed I'm uploading a resized photo. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.