ReminderVDP Posted February 4, 2013 Share Posted February 4, 2013 I am trying to break a line of text at a hyphen in someone's title with a rule and can't figure out how. Currently, the title will break like this based on the copyfit rule. Director - Wealth Management I'd like it to break after the hyphen so it reads like this: Director - Wealth Management Any ideas? Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted February 4, 2013 Share Posted February 4, 2013 Create a new rule like this: return Field("Title").replace("- ", "-<br>"); Turn on treat strings as tagged text. Quote Link to comment Share on other sites More sharing options...
digitalsig-1.com Posted March 4, 2014 Share Posted March 4, 2014 Create a new rule like this: return Field("Title").replace("- ", "-<br>"); Turn on treat strings as tagged text. I need to use this rule to replace ALL semicolons in a field with line breaks, but what I get is literally <br> inserted between the text in place of the semicolon, and it only does it the first time and ignores all other occurrences. How can I replace all instances of a semicolon with line breaks in a variable field.? Quote Link to comment Share on other sites More sharing options...
David Miller Posted March 4, 2014 Share Posted March 4, 2014 I need to use this rule to replace ALL semicolons in a field with line breaks, but what I get is literally <br> inserted between the text in place of the semicolon, and it only does it the first time and ignores all other occurrences. How can I replace all instances of a semicolon with line breaks in a variable field.? You can try: return Field("MyFieldName").replace(/;/[color="Red"]g[/color], "<br>"); The red g = global match. More info on the replace() method can be found here. Quote Link to comment Share on other sites More sharing options...
digitalsig-1.com Posted March 4, 2014 Share Posted March 4, 2014 ...almost there... but not quite. still need to figure out why I get <br> literally (or <p>) instead of a line break (or paragraph return). see screenshot Quote Link to comment Share on other sites More sharing options...
David Miller Posted March 4, 2014 Share Posted March 4, 2014 Check the box next to "Treat returned strings as tagged text" in the Rule Editor. It needs to be turned on in this case. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 4, 2014 Share Posted March 4, 2014 Check the "Treat returned strings as tagged text" box in the Rule Editor. Also, to avoid problems with certain markup characters which may already be present in the data, you probably also want to change the rule to this: return TaggedTextFromRaw(Field("MyFieldName")).replace(/;/g, "<br>");Or, if you might be submitting this job to a web-to-print system such as MarcomCentral, which may be generated a tagged markup data file for the job, this is the ideal solution: return TaggedDataField("MyFieldName").replace(/;/g, "<br>"); Quote Link to comment Share on other sites More sharing options...
digitalsig-1.com Posted March 4, 2014 Share Posted March 4, 2014 yep - that was the secret Quote Link to comment Share on other sites More sharing options...
dschiller Posted June 6, 2014 Share Posted June 6, 2014 Or, if you might be submitting this job to a web-to-print system such as MarcomCentral, which may be generated a tagged markup data file for the job, this is the ideal solution: return TaggedDataField("MyFieldName").replace(/;/g, "<br>"); I've tried using this code and I've gotten it to validate and work when I'm using FusionPro in Adobe Acrobat, but when I upload the template to MacromCentral and try to preview the rule in effect, it doesn't recognize it and only prints a semicolon instead of the line break. I've even downloaded the template from the website and reopened it up in Acrobat to find that the rule is still there and working. It's only when I attempt to put it online that it doesn't. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 6, 2014 Share Posted June 6, 2014 I've tried using this code and I've gotten it to validate and work when I'm using FusionPro in Adobe Acrobat, but when I upload the template to MacromCentral and try to preview the rule in effect, it doesn't recognize it and only prints a semicolon instead of the line break. I've even downloaded the template from the website and reopened it up in Acrobat to find that the rule is still there and working. It's only when I attempt to put it online that it doesn't. Are you sure you're uploading the new .def file with the changes to the rule? I would add some debugging to the rule, like so: var originalText = TaggedDataField("MyFieldName"); var newText = originalText.replace(/;/g, "<br>"); Print('original text "' + originalText + '", changed to "' + newText + '"'; return newText; And look in the composition log file to see what it says. In MarcomCentral, if you view the output PDF in your web browser, you can change the extension at the end of the URL from .pdf to .msg to see the log file. Quote Link to comment Share on other sites More sharing options...
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.