Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. Yeah, you can do that with an OnRecordStart callback rule. For example, if a user enters information in a "Duplex" field, you want to enable the 2nd page but if the "Duplex" field does not contain any data, you want to suppress the 2nd page: FusionPro.Composition.SetBodyPageUsage(2, Field("Duplex"));
  2. That's a good question, Gregg. I don't really remember but if I had to guess, I'd say it was to include a little "wiggle room" in case the measurement of the text wasn't entirely accurate. I've noticed that sometimes if you set the width of the table to the exact width of the text, the text can occasionally overflow so multiplying the width by 1.1 just adds a 10% buffer.
  3. The reason that it validates correctly and doesn't display the right thing is this: tm.maxWidth = FusionPro.inValidation ? 7200 : GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.[color="Red"]FormatAddress[/color])); That line of code sets the max width to the width of the current text frame. At the point of validation, the width of the current text frame is not known so I've manually set it to 7200 (or 1 inch) for validation purposes. "FormatAddress" is not a property of FusionPro.Composition.CurrentFlow. That should be changed to: tm.maxWidth = FusionPro.inValidation ? 7200 : GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name)); Or (assuming your text frame is named "FormatAddress"): tm.maxWidth = FusionPro.inValidation ? 7200 : GetSettableTextWidth(FindTextFrame("FormatAddress")); Once you fix that, you probably still won't get the results you're looking for because you don't call either of the functions that you created. I think you want to do something like this: function AllowPipe(input){ tm = new FusionProTextMeasure; tm.font = 'Lato Bold'; tm.pointSize = '87 pt'; tm.maxWidth = FusionPro.inValidation ? 7200 : GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name)); tm.CalculateTextExtent(input); return tm.textLines == 1; } var replace = { 'Boulevard': 'Blvd', 'Street': 'St', 'Terrace': 'Ter', 'Avenue': 'Ave', 'Road': 'Rd' }; var address = [ [Field("address"), Field("address2")].filter(String).join(', '), Field("city") ].filter(String).join(' | '); for (var find in replace) address = address.replace(new RegExp(find, 'gi'), replace[find]); if (!AllowPipe(address)) address = address.replace(' | ', ' '); return address;
  4. You can give this a shot: function AllowPipe(input){ var tm = new FusionProTextMeasure; tm.font = 'Helvetica'; tm.pointSize = '12 pt'; tm.maxWidth = FusionPro.inValidation ? 7200 : GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name)); tm.CalculateTextExtent(input); return tm.textLines == 1; } var address = [Field("Street Address"), Field("Ste or Office number"), Field("City")].filter(String).join(' '); if (AllowPipe(address) && Field("City")) address = address.replace(' ' + Field("City"), ' | ' + Field("City")); return address; Make sure that you give the text frame that will be returning the rule a unique name. Otherwise, you'll have to manually specify the width of the text frame (in 1/100th's of a point). Then in the rule editor, make sure that you've checked "Re-evaluate this rule for every text flow."
  5. As would this assuming you're okay with formatting every year as 20##: var date = Field("InductionDate").replace(/[-\s]|(\d+)$/g, function(s,p) {return p ? '20' + p.slice(-2) : ' ' }); return FormatDate(new Date(date), 'd lm yyyy');
  6. Set each of your "TOC Title #" rules to "Re-evaluate this rule for every text flow"
  7. I don't use MarcomCentral so I really don't know. You could ask that question on the MarcomCentral forum, though, and someone could probably help. Gotcha. Sorry, I didn't realize you were returning a graphic rule. You could use the CreateResource function instead if you'd like: return IsPreview() ? CreateResource('/path/to/your.pdf', 'graphic') : NullResource();
  8. Are you trying to suppress the text frames when you're in the composition stage? As in: suppress the frames when not in preview and show them when in preview? If so: FindGraphicFrame("Die Front").suppress = !IsPreview(); FindGraphicFrame("Die Back").suppress = !IsPreview();
  9. return IsPreview() ? Resource("PreviewBlackHours") : '';
  10. Assuming you're still trying to make this idea work for you, it's not really as simple as what's in this thread. The great thing about rules is the control they give you over how you want to format a particular string based on the data you have. In the example you've quoted, number descriptors ("Tel:", "Fax:", etc) are added based on whether or not those data fields are populated and then the resulting string is returned. What you're trying to accomplish is setting the format and then attempting to create a rule to re-format it to match the data. In the interest of keeping this thread somewhat on topic, here's an example: var numbers = { 'Tel': '123 456 7890', 'Mobile': '', 'Fax': '456 555 1230' }; var result = 'Tel: ### ###-####, Mobile: ### ###-####, Fax: ### ###-####'; for (var i in numbers) result = result.replace(i + ': ### ###-####', i + ': ' + numbers[i]); return result.split(', ').filter(function(s){ return /\d/.test(s);}).join(', '); The alternative (and possibly better) solution is to just replace the entire placeholder string with your rule instead of trying to replace each variable individually: var numbers = { 'Tel': '123 456 7890', 'Mobile': '', 'Fax': '456 555 1230' }; var paragraph = 'Contact us today at: Tel: ### ###-####, Mobile: ### ###-####, Fax: ### ###-####'; var placeholder = 'Tel: ### ###-####, Mobile: ### ###-####, Fax: ### ###-####'; var replace = []; for (var i in numbers) if (number = numbers[i]) replace.push(i + ': ' + number); return paragraph.replace(placeholder, replace.join(', '));
  11. You can get the number of pages in a record by calling FusionPro.Composition.totalPages. You can format it to two digits by using the FormatNumber function: var pgs = FormatNumber('00', FusionPro.Composition.totalPages); // Whatever barcode logic here
  12. You can't re-order pages in your template from OnRecordStart – you can only turn them on/off. Is that a requirement? If so, I would suggest having a 5 page template with pages 1, 2, 4, and 5 as static pages that always return pages 1, 2, 49 and 50 (respectively) and the 3rd page being an overflow page that adds a random number of pages, each pulling a different random page from the other 46 pages: var pdf = CreateResource('path/to/your.pdf', 'graphic'); var pages = []; for (var i=2; i<49; i++) pages.push(i); return pages .sort(function(){ return .5 - Math.random(); }) .splice(0, Math.floor((Math.random() * pages.length) + 1)) .map(function(s){ pdf.pagenumber = s; return pdf.content; }) .join('<p>'); If you don't mind if they stay in order, you can variably turn random pages on and off like this: for (var i=2; i<49; i++) if (Math.round(Math.random())) FusionPro.Composition.SetBodyPageUsage(i, true);
  13. 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?"
  14. Maybe you could post the template and data that you're working with so that we could take a closer look? My guess is that your template is converting those special characters to their HTML entities. Meaning the < is converted to < and the > is converted to >. So your find pattern is unable to come up with a match. I imagine the same is true for the daggers. If that assumption is true, this will probably work for you: var chars = { // Find: Replace: '\\^': '<superscript>^</superscript>', '\\+': '<superscript>+</superscript>', '[color="red"]†[/color]': '<superscript>†</superscript>', '[color="Red"]‡[/color]': '<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"), '<<more>>': Rule("MoreR"), '<<actual>>': Rule("ActualR"), '<<winno>>': Field("WinNo"), } var text = FindTextFrame('FullBody').content .replace(/<variable name="([^"]*)">/g, function(s,p) { return FieldOrRule(p); }) [color="red"] .replace(/&([lg])t;/g, function(s,p) { return p == 'l' ? '<' : '>'; });[/color] for (var i in chars) text = text.replace(new RegExp(i, 'g'), chars[i]); FindTextFrame('FullBody').content = text;
  15. I converted the '<variable name="...">' tags to the actual strings that they're supposed to return before replacing the symbols in case a field or rule being returned in the text frame contains one of the symbols.
  16. var chars = { // Find: Replace: '\\^': '<superscript>^</superscript>', '\\+': '<superscript>+</superscript>', '<<first>>': Field("First Name"), } var text = FindTextFrame('FullBody').content .replace(/<variable name="([^"]*)">/g, function(s,p) { return FieldOrRule(p); }); for (var i in chars) text = text.replace(new RegExp(i, 'g'), chars[i]); FindTextFrame('FullBody').content = text;
  17. You could try putting this in your OnRecordStart rule: var chars = [ '\\^', '\\+', // Add as many as you like ]; var text = FindTextFrame('FullBody').content .replace(/<variable name="([^"]*)">/g, function(s,p) { return FieldOrRule(p); }) .replace(new RegExp('(' + chars.join('|') + ')', 'g'), '<superscript>$1</superscript>'); FindTextFrame('FullBody').content = text; The above code will superscript all occurrences of +/^ in a text frame named "FullBody." You can add additional characters to be superscripted to the 'chars' array. Keep in mind that both plus signs and carets have special meanings in regular expressions so they must be escaped.
  18. Sure, that seems like it would work. It's also worth mentioning that FusionPro converts your EPS files to PDF files during composition. So if you're going to go through the trouble of creating JPGs and adding new data fields, you might also have success with just creating the PDFs of the EPS files yourself and adjusting the settings until you get the output you and the client both find acceptable. Then you could just use the PDF graphics and not worry about switching them based on output status (i.e. print/download).
  19. If you want to swap out the image resources that the template is using, I believe you'll have to create both an EPS version and a JPG version and write a rule to determine which to pull in based on whatever logic you're using to display a watermark. Alternatively, in the composition settings, you can select "JPEG Options" under the "Output" tab and enable JPEG output. Doing this will create a jpg of the output (in addition to the PDF or whatever you're creating for print) which you could allow the client to download and print. Speaking of the client, how are they accessing the template/downloading proofs? If it's through MarcomCentral, you might get a more helpful/specific response by moving this post to the MarcomCentral forum.
  20. Have you searched the forum? http://forums.pti.com/showthread.php?t=3065
  21. Try this: if (Field("Email") != "") return CopyfitLine(Resource("FCBCIconsEmail.pdf")[color="Red"].content[/color] + " ", Field("Email")+ "@" +Field("emailDomain"), "Vaud", 8, 228, 4, true); else return "";
  22. Try this: if (Field("Phone1") == "") return "" else return Resource("Phone")[color="Red"].content[/color] + (Field("Phone1"));
  23. return [ Field('Field1'), Field('Field2'), Field('Field3'), Field('Field4'), Field('Field5'), Field('Field6'), Field('Field7'), Field('Field8'), Field('Field9'), Field('Field10'), Field('Field11'), Field('Field12'), Field('Field13'), Field('Field14'), Field('Field15') ].filter(String).join(' | '); Or if your fields are really named "Field" + number, you could create the array with a for loop: var fields = []; for (var i = 1; i <= 15; i++) fields.push(Field("Field" + i)); return fields.filter(String).join(' | '); The '.filter(String)' method removes any elements in the array that aren't strings – any fields that aren't used. The '.join(" | ")' method joins the remaining elements in the array with a space, a pipe and a space.
×
×
  • Create New...