Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. You need to put quotes around your tags: var fax = Rule("fax_Rule"); if (fax.length > 0) { return fax + " " + [color="Red"]"[/color]<b>F</b>[color="red"]"[/color] ; } Or: var fax = Rule("fax_Rule"); if (fax) return fax + " <b>F</b>";
  2. You could try this: var [date, cutOff] = [ Field("YOUR DATE FIELD HERE"), "6/13/2017" ].map(DateFromString); return date < cutOff ? "before value" : "after value";
  3. I don't understand why you wouldn't just adjust the text frames so that they won't wrap. If you always want the text to start at a specific Y-coordinate, what's the point of vertically centering something? You could just vertically align your text frames to the top, reduce the height of the text frame and voila – your text is truncated to one line. Again, I think you're really over-thinking this one. Why stress over coding a solution that could be fixed by making a few tweaks to the text frame.
  4. There may be an easier way to accomplish this, but you could probably get the results you want by using linked text frames and the "verticalstart" attribute of the paragraph tag. You'd create a rule that returned the content of both pages joined by a paragraph tag that forces the contents of the back page to start at the top of the "next page". If the contents of the front page overflows onto the second page, starting the back contents on the "next page" effectively tells the text to overflow to a 3rd linked frame and since a 3rd linked frame doesn't exist, the text won't fit. So, we can modify the OnCopyfit rule to check whether or not the text fits. If it fits, we can assume that the front page did not need to overflow to the second page, if it doesn't fit, we need to remove the "verticalstart" attribute from the paragraph tag so that it will fall inline with the overflowed text. Here's an example: Text Rule: var spaceBetweenParagraphs = 1000; // 1000 = 10 pts var front = 'Tofu palo santo bespoke kombucha, leggings health goth prism VHS everyday carry adaptogen actually asymmetrical iPhone single-origin coffee. Tote bag subway tile gochujang cliche schlitz tattooed XOXO, succulents edison bulb hella. Tote bag banjo iPhone, actually selvage fixie gochujang hell of retro palo santo taxidermy keytar microdosing ethical normcore. Next level ennui truffaut taiyaki, food truck chartreuse you probably haven\'t heard of them iceland. Enamel pin kickstarter meditation locavore. Actually lo-fi succulents, dreamcatcher slow-carb cray viral activated charcoal gochujang irony af palo santo meggings tofu. Bushwick celiac keytar, affogato chia pour-over semiotics artisan chicharrones cold-pressed.' // Uncomment paragraphs below to demonstrate inline back page. // + '<p leadbefore="' + spaceBetweenParagraphs + '">Humblebrag yuccie craft beer semiotics sartorial forage pork belly polaroid, distillery hoodie. Neutra activated charcoal cronut quinoa pickled, whatever occupy. Humblebrag ramps tumeric forage, messenger bag meditation 90\'s synth. Kickstarter pork belly deep v, raw denim activated charcoal vaporware synth. Umami cornhole hoodie, live-edge letterpress small batch hella vexillologist. Af venmo food truck fap, plaid cardigan edison bulb tilde. Art party tofu health goth vaporware sustainable.' // + '<p leadbefore="' + spaceBetweenParagraphs + '">PBR&B beard pitchfork, bushwick tumblr meggings blue bottle man braid pop-up la croix aesthetic tote bag post-ironic yr. Selfies intelligentsia poke plaid, pinterest live-edge tattooed banjo typewriter flannel photo booth bitters drinking vinegar. Tumblr meggings lyft authentic, raw denim af biodiesel 3 wolf moon semiotics banh mi health goth squid. Copper mug offal sartorial hell of gentrify, air plant kinfolk crucifix adaptogen austin affogato la croix. Tumeric live-edge tacos literally williamsburg, DIY roof party raw denim cardigan jianbing irony austin deep v. Quinoa kickstarter church-key, schlitz raclette stumptown gluten-free ugh mlkshk neutra helvetica tattooed small batch. Intelligentsia stumptown hashtag, cronut wolf pinterest YOLO 90\'s taxidermy VHS wayfarers tattooed raw denim franzen master cleanse.' // + '<p leadbefore="' + spaceBetweenParagraphs + '">Coloring book salvia health goth wayfarers edison bulb, church-key actually you probably haven\'t heard of them tote bag beard twee chillwave 3 wolf moon hoodie. Farm-to-table locavore roof party cray. YOLO banjo man braid ugh cloud bread. Microdosing everyday carry cred, mixtape master cleanse hexagon snackwave you probably haven\'t heard of them kombucha gentrify chicharrones bicycle rights ugh fixie letterpress. Enamel pin poke letterpress, pour-over prism mixtape echo park kickstarter hexagon artisan copper mug offal blue bottle crucifix. Palo santo microdosing blog, ethical irony lomo single-origin coffee swag hashtag raclette farm-to-table blue bottle selfies master cleanse chartreuse. Leggings lo-fi yuccie, lyft umami mustache polaroid snackwave celiac.' var back = 'Literally chartreuse master cleanse, tilde glossier locavore put a bird on it VHS succulents celiac craft beer. La croix direct trade readymade organic mixtape, kitsch 8-bit blog iPhone try-hard live-edge slow-carb. Flexitarian polaroid forage cold-pressed, occupy poutine portland tacos vice gastropub. Everyday carry dreamcatcher health goth next level neutra kombucha, heirloom tousled affogato pork belly retro. Irony chambray occupy, gastropub keytar woke four loko butcher ugh vinyl tumeric umami man bun lumbersexual edison bulb. Literally ethical readymade activated charcoal, knausgaard PBR&B mixtape small batch hashtag woke. Blue bottle readymade semiotics, jianbing fashion axe keytar craft beer plaid keffiyeh lyft actually iPhone 8-bit.'; return [front, back].filter(String).join('<p verticalstart="topofpage">'); OnCopyfit: var cf = FusionPro.Composition.CurrentFlow; // If it doesn't fit, don't start back page at "topofpage" if (!cf.fits) cf.content = cf.content.replace(/<variable name="([^"]+)">/g, function(s,p) { return RuleOrField(p).replace('verticalstart="topofpage"', ''); }); // Regular Copyfitting... if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) ReportWarning("Could not copyfit text in flow " + cf.name);
  5. Yeah, JavaScript is classically used to interact/manipulate with the DOM in a web browser. Obviously, since FusionPro is not executed within the context of a web browser, there will be some differences between the code found on this forum and a generic JS related article found on the internet. That said, the syntax of the actual JavaScript code are the same across both. The main difference is that FusionPro has supplied built-in functions and methods that allow you to interact with the FP plugin. The "Field" function, the "FusionPro.Composition.SetBodyPageUsage" method, etc are specific to FusionPro and won't be found in an Angular app (for example). The "Functions" and "Objects" tabs of the "Building Blocks" dialog window define what most of those built-in functions do. But, if you're ever unsure of how a snippet of code found on this forum works, you should feel free to ask.
  6. Can you post the code you're using to correctly generate the "North" logos?
  7. Yes, the original script you posted returns an array – the elements within the array are separated by a comma when output. The join method joins the elements with something other than a comma and converts the returned element to a string. So, in your second snippet, you're joining the element with a tab tag. But you could join them with a break tag (<br>) like in the original script, or a space, or any ole' string you want, really: var cellImg = Resource("cell").content; var voiceImg = Resource("voice").content; var faxImg = Resource("fax").content; var emailImg = Resource("email").content; var numbers = [ [Field('EMAIL'), emailImg], [Field('PHONE'), voiceImg], [Field('CELL'), cellImg], [Field('FAX'), faxImg] ].filter(function(s){return s[1]}).map( function(s){ return '<p br=false superoffset=70 superratio=100>' + s[1] + '<superscript> ' + s[0] + '</superscript>'; }) return numbers[color="Red"].join("any ole' string you want");[/color]
  8. I think you want to do something like this: var logoField = Field("logo"); // Your logo field var logos = { A:[ // Logos that use frame "A" ], B:[ // Logos that use frame "B" "sports medicine.pdf", "neurosurgery.pdf", "pain management.pdf", "primary care.pdf" ], C:[ // Logos that use frame "C" ] }; for (var frame in logos) FindTextFrame(frame).suppress = logos[frame].indexOf(logoField) === -1;
  9. I understand this is a relatively old post, but I've been battling this bug all week and thought I'd share another workaround. I've noticed in the past that toggling "use legacy line leading" will sometimes remedy the issue (as previously noted in this thread) but I'm still unclear as to why that is. Furthermore, I think FusionPro has begun to rework the way it handles leading – so relying on "legacy" leading as a workaround did not sit well with me. While thumbing through the section on tables in the TagsRefGuide, I noticed a "space" attribute and found that if you define space above (or below) the table, all of the cells magically become centered again: var myTable = new FPTable; myTable.AddColumns(16000, 6000, 6000, 6000, 6000, 6000); // Add the top row var topRow = myTable.AddRow(); topRow.Cells[0].HAlign = "Center"; topRow.Cells[0].VAlign = "Middle"; topRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left"); topRow.Cells[0].Font="Times New Roman"; topRow.Cells[0].PointSize=11; topRow.Cells[0].Bold="On"; topRow.CopyCells(0,1,2,3,4,5); topRow.SetContents("Your Monthly Amount", "$100", "$250", "$500", "$1,000", "$5,000"); // Add the bottom row var bottomRow = myTable.AddRow(); bottomRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left"); bottomRow.Cells[0].ShadeColor="Black"; bottomRow.Cells[0].ShadePct=15; bottomRow.Cells[0].Font="Times New Roman"; bottomRow.Cells[0].PointSize=11; bottomRow.Cells[0].Bold="On"; bottomRow.CopyCells(0,1,2,3,4,5); bottomRow.SetContents("Our Offer To You", "100", "250", "500", "1000", "5000"); // Center the table in the text box return myTable.MakeTags().replace(/^\<table/, '<table [color="red"]space="above:1"[/color] alignment=center'); If you actually want to add space above/below the table, then it's worth mentioning that the value should be in 10ths of a point but any value greater than 0 fixes the alignment issue. More info can be found on page 56 of the TagsRefGuide.pdf
  10. What is the format of the "Date" field? You could try this: MyDate = FormatDate(DateFromString(Field("Date")), "ld, lm d, yyyy");
  11. I see. You could just set that to a variable that returns an empty string when the record numbers are undefined: var records = input[3] ? '_' + input[3] : '';
  12. Yes, it would work for all of those scenarios. Here's a breakdown of what I mean by "splitting the input file name at the underscores" that may make it easier to visualize: var input = PrimaryInputFile(); // /path/to/20170405A_STD_DM_1-50000-.txt input = GetFileName(input); // 20170405A_STD_DM_1-50000-.txt input = input.split('_'); // [ '20170405A', <--- input[0] // 'STD', <--- input[1] // 'DM', <--- input[2] // '1-50000-.txt']; <--- input[3] As you can see, when the file name is split at the underscore, the first position in the resulting array (input[0]) will be the correct run number regardless of whether an A or B is used since it simply takes everything up until the first underscore as that value. I don't know what that means.
  13. You don't need to use regexp matching for this. Why not just split the input file name at the underscores? var input = GetFileName(PrimaryInputFile()).split('_'); FusionPro.Composition.outputFileFullPathName = 'D:\\FPDirect\\Submitted\\RUN ' + input[0] + '\\' + input[0] + '_' + input[2] + '_ALL\\' + ReplaceFileExtension(input.join('_'), FusionPro.Composition.outputFormatExtension);
  14. Parentheses have special meaning in regular expressions. You need to escape them (and close the 'Trim' function): return Trim(Field("Comment")[color="red"])[/color].replace(/:[color="Red"]\[/color])/g,'☺');
  15. No clear answer? I thought I was pretty clear in my answer to a very similar question in this thread. The only difference is that you want to insert an extra page when the tray number changes and the original poster wanted to insert an extra page when the stack height hit 100. The error you're getting is because the FP imposition you've defined is for 1 page per record but when the tray number changes you're trying to compose 2 pages per record (your postcard page and your "break" page). Instead, you need to change your logic to repeat the record twice when the tray number changes – once with the "break" page enabled (and postcard page disabled) and once with the postcard page enabled (and "break" page disabled). That will give you the results you're looking for while still conforming to the imposition you've defined for FusionPro. This assumes that the "postcard" is on a body page named "postcard": FusionPro.Composition.SetBodyPageUsage("Break", false); if (FieldChanged("TRAYNUMBER")) { FusionPro.Composition.repeatRecordCount = 2; FusionPro.Composition.SetBodyPageUsage("Break", FusionPro.Composition.repeatRecordNumber%2 == 1); FusionPro.Composition.SetBodyPageUsage("postcard", FusionPro.Composition.repeatRecordNumber%2 == 0); }
  16. The problem is that when FusionPro preprocesses the job, the "processedRecordNumber" is zero-indexed (the first record is 0) but when it composes the job the first record is "1". FusionPro preprocesses the job to determine how to layout the records on the imposition you've defined for the job. So on the first record (record 0 during preprocessing) it checks the 'versions' object for the version and adds it. Then on the second record (record 1 during preprocessing), it resets the 'versions' object, checks for the version and determines that record 2 should also print even though they're the same version. Ultimately, the issue is that FP gets confused when the layout determined during preprocessing doesn't match what the template is saying should print during composition. The fix is to only reset the 'versions' object if FusionPro is done preprocessing: if (FusionPro.Composition.processedRecordNumber == 1[color="Red"] && !FusionPro.Composition.inPreprocessing[/color]) versions = {}; var isProof = true; // false to compose job normally var version = Field("list"); // Field that indicates version if (isProof) { if (!versions[version]) versions[version] = 0; FusionPro.Composition.composeThisRecord = ++versions[version] <= 1; }
  17. That doesn't have the year in it, either so I'm not sure why you're seeing the code reflect the year. function getOrdinal(n) { var s = ["th","st","nd","rd"]; return n + (s[(n-20)%10] || s[n] || s[0]); } MyDate = '5/13/17'; return FormatDate(MyDate, "lm d").replace(/(\d+)$/, getOrdinal); // May 13th Yes, you can use the 'superscript' to superscript the ordinal: function getOrdinal(n) { var s = ["th","st","nd","rd"]; return n [color="Red"]+ '<superscript>'[/color] + (s[(n-20)%10] || s[n] || s[0])[color="red"] + '</superscript>'[/color]; } MyDate = DateFromString(Field("f123_DueToRenewDateString")); return FormatDate(MyDate, "lm d").replace(/(\d+)$/, getOrdinal); The below gives the you flexibility to add the year if you choose: function getOrdinal(n) { var s = ["th","st","nd","rd"]; return s[(n-20)%10] || s[n] || s[0]; } MyDate = DateFromString(Field("f123_DueToRenewDateString")); return FormatDate(MyDate, 'lm d') + '<superscript>' + getOrdinal(MyDate.getDate()) + '</superscript>' // + ' ' + FormatDate(MyDate, 'yyyy'); // Uncomment to include year.
  18. Please paste the code you're using. You've obviously changed it from what you originally posted since the 'FormatDate' function originally just output the month and day. function getOrdinal(n) { var s = ["th","st","nd","rd"]; return n + (s[(n-20)%10] || s[n] || s[0]); } MyDate = DateFromString(Field("f123_DueToRenewDateString")) ; return FormatDate(MyDate,[color="Red"] "lm dd"[/color]).replace(/(\d+)$/, getOrdinal);
  19. True – assuming that the first page in your template has 0 active fields, the second page has 1 active field, etc and if the card has a back it is the last page in the template.
  20. Sure, you can put this in your OnRecordStart callback: var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length; FusionPro.Composition.SetBodyPageUsage(activeFields, true); Note: the above code assumes you've named the pages in your template 0–4 and have them set to "Unused."
  21. You could try using a 2 column table with a blue border set on the right side of the first column: var numbers = [ ['o', Field("Office")], ['e', Field("Extension")], ['f', Field("Fax")], ['c', Field("Cell")], ['', '1835-A Forest Drive<br>Annapolis, MD 21401'] ].filter(function(s){ return s[1] }); var table = new FPTable(); table.AddColumns(0.5 * 7200, 2 * 7200); // Left column is .5", right column is 2" numbers.forEach(function(num) { var row = table.AddRow(); row.Cells[0].SetBorders('Thick', 'Blue', 'Right'); var [abbreviation, number] = num; if (abbreviation) abbreviation = '<color name="Orange">' + abbreviation + '</color>'; row.SetContents(abbreviation, number); }); return table.MakeTags();
  22. Looks like you copy and pasted wrong. Try replacing all of the code in your rule editor with the all of the code from the code block in my post.
  23. I grabbed an ordinal function from this post and modified it slightly (the v variable isn't necessary since a date will never be higher than 31 – much less 100). Then I just replaced the date with the returned value from the getOrdinal function for the matched date: function getOrdinal(n) { var s = ["th","st","nd","rd"]; return n + (s[(n-20)%10] || s[n] || s[0]); } MyDate = DateFromString(Field("f123_DueToRenewDateString")) ; return FormatDate(MyDate, "lm dd").replace(/(\d+)$/, getOrdinal);
  24. var barcode = '92148901066154000105004961'; return barcode.match(/(\d{1,4})/g).join(' ');
  25. Have you tried removing the position="afterline" attribute? I don't think it's necessary. By the way, the code in your template is quite repetitive and could be made more concise if you want: var firstPage = 'First'; var lastPage = 'Last'; var firstGraphic = 'graphic'; var lastGraphic = 'graphic_last'; var isUpload = /Upload/.test(Field("Product Name")); var path = "c:/SpecBen/" + (isUpload ? "uploadPDF" : "staticPDF") + "/"; var fileName = (isUpload ? Field("Order Number") + "-" + Field("SKU") : Field("Product Name")) + ".pdf"; var result = []; if (Field("Product Name") == "Coverage Change Form") { firstPage += 'L'; lastPage += 'L'; firstGraphic += '2'; lastGraphic += '2'; } //Print an address page at beginning of each order if (FieldChanged("Order Number")) FusionPro.Composition.SetBodyPageUsage("address", true); FusionPro.Composition.SetBodyPageUsage(firstPage, true); FusionPro.Composition.SetBodyPageUsage(lastPage, true); var file = CreateResource(path + fileName, 'graphic'); var pages = file.countPages; for (var i = 1; i < pages; i++) (file.pagenumber = i) && result.push(file.content); file.pagenumber = pages; FindTextFrame(firstGraphic).content = result.join('<p>'); FindTextFrame(lastGraphic).content = file.content;
×
×
  • Create New...