Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. Alot of the code that you've written isn't doing anything. For example: outstr = ""; itemName = "ulOne"; You've set the global variable "outstr" to be an empty string. Then you set the global variable "itemName" to be "ulOne" – which appears to be the name of the field you're using later in the rule. That part makes sense. if(itemName != "ulOne"){ Then you check to see if the 'itemName' variable (which you just set to "ulOne") is not equal to "ulOne." Anything in that conditional will not be executed so it's kind of pointless to put it there. else if(outstr == null){ return itemName.suppress; You're checking to see if "outstr" is null when you just set its value to an empty string. If you wanted to check to see if anything had been added to that variable, you should do something like: else if (outstr == "") // or: else if (!outstr)It doesn't really matter though because ".suppress" is not a function of a string ("itemName") and it would throw you an error. You probably just want to check if the field is empty before adding a bullet to it like this: var bullet = ' • '; var itemName = 'ulOne'; var result = ""; if (Field(itemName)){ result = bullet + Field(itemName); } return result; Or to apply a bullet to the start of every paragraph (more details here): var bullet = ' • '; var itemName = Field("ulOne"); return itemName.split("<p>").filter(String).map(function(s){return bullet + s;}).join("<p>");
  2. If you feel like collecting the job, I can take a look at it.
  3. In your "Paragraph settings" do you have "Suppress if: Empty" checked?
  4. Personally, I've never used MarcomCentral (there's a completely separate forum for MC specific questions that you may have better luck with) but if it's always defaulting to the purple color, I would think that MC is reading the value of the "headerImage" field differently than FP is locally. My suspicion is that in MC perhaps the field value is prepended with a path to the pdf? If that's the case, one way to get around that would be to use the "GetFileName" function to basically remove the path from the field value when checking if it's equal to "red.pdf" or whatever value: if(GetFileName(Field("headerImage")) == ("red.pdf")){ return redSubOne.toUpperCase(); } . . . As a side note, you really shouldn't need to make that entire line ('redSubOne') all uppercase since it contains your tags. Instead you could just force the field itself to uppercase when you're defining the variable and leave the tags untouched: var redSubOne = "<color name = \"PANTONE Red 032 C\">" + ToUpper(Field("dynamicSubOne")) + "</color>"; You may also want to take advantage of a switch statement here in lieu of all of the "else if" statements which would allow you to clean the code up a bit: var color = ''; switch (GetFileName(Field("headerImage"))){ case "red.pdf": color = "PANTONE Red 032 C"; break; case "blue.pdf": color = "PANTONE 2945 C"; break; case "gray.pdf": color = "PANTONE 430 C"; break; default: color = "PANTONE 266 C"; } return '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>'; If the issue value of the field is differing on MC by more than just a prepended path (casing for example), I suppose you could do a more generic search of that field value and search for any presence of "red.pdf" in "headerImage" regardless of casing by using a regular expression and modifying the code to look like this: var header = String(Field("headerImage").match(/(red|blue|gray)\.pdf/ig)); var color = ''; switch (ToLower(header)){ case "red.pdf": color = "PANTONE Red 032 C"; break; case "blue.pdf": color = "PANTONE 2945 C"; break; case "gray.pdf": color = "PANTONE 430 C"; break; default: color = "PANTONE 266 C"; } return '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>'; That would match "red.pdf", "RED.pdf", "/path/to/red.PDF", etc.
  5. My hunch is that FP is only adding an output file number after the first chunk has been exceeded. My suggestion would be to use an OnNewOutput callback rule to append the output file number to the name since it will call that function to figure out what to name the file. I haven't tested this and without your actual pdf FP template, I can't test it for your use case (without editing your .def file) but it seems like it would work: OnNewOutputFile if (!IsPreview()){ FusionPro.Composition.outputFileName = FusionPro.Composition.outputFileName.replace(/\.\w*$/,'') + "_" + FusionPro.Composition.currentOutputFileNumber + "." + FusionPro.Composition.outputFormatExtension; } And I think at one point I had to physically call the OnNewOutputFile from OnJobStart but since you're chunking the data in your composition settings, I don't think you would need to. But just in case: OnJobStart if (!IsPreview()){ Rule("OnNewOutputFile"); }
  6. In the variable text editor, highlight the line of text you want to "collapse", click "Paragraph," and select "Suppress if containing empty variables." To do this in a text rule: var name = Field("Name"); return (name) ? "My name is " + name + "!" : "";
  7. Good I'm glad that's working for you! No props necessary though I appreciate it.
  8. The regular expression is starting at the end of the file and matching the extension, the period, and then as many numbers as it can find so in your example it would match (in red): As long as you have the underscore separating the JobName, you should be safe.
  9. David, that sounds like the issue that was being discussed here where there was a 1 being appended to the file name in earlier versions of FP9. However, Dan also says that problem was fixed in the 9.3.12 release so if you're running 9.3.15, I wouldn't think it's the same problem but it sounds too familiar not to bring up. That being said, I guess you could try to remove all numbers preceeding the extension and replacing it with the formatted output file number (rather than just replacing the output file number and extension): FusionPro.Composition.outputFileName = FusionPro.Composition.outputFileName.replace(new RegExp('\\d*\\.' + FusionPro.Composition.outputFormatExtension + '$',''), function(){return FormatNumber("000", FusionPro.Composition.currentOutputFileNumber) + "." + FusionPro.Composition.outputFormatExtension;});
  10. Awesome I'm glad that worked for you!
  11. If you want to set up the template with 10 variable text frames (like your screenshot), you don't really need a data file at all. You'd set your OnJobStart Callback rule to look like this: FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.endRecordNumber = 2000; // Number of press sheets Then set a global variable: var ticket = 122750; // starting ticket number Create a text rule (with "Re-evaluate this rule for every text flow" checked): return ticket++; Apply that rule to every text frame. The ticket numbers will increment in the order that the frames were created.
  12. Well you need to make it a string by putting quotes around it: return '<stroke color="White" width="3000">HELP</stroke>'; To add a variable field you'd have your literal strings in quotes and your variables added to the string: return '<stroke color="White" width="3000">' + Field("Name") + '</stroke>';
  13. It doesn't look like you followed that step (pardon my pun). Open up your "InsertPicture_New Rule" rule and tick the box beside "Re-evaluate this rule for every graphic frame" above the "expressions" text frame and beneath the "Comment" text frame. And while you can do this: "1": Resource("Heart disease1.pdf"), It's easier to just apply the resource function at the return line. Not to mention, you'd have to do it for every resource in that object. Your template works for me when I set the rule to re-evaluate for every graphic frame and have the code as: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3] = [Field("P1"),Field("P2"),Field("P3"),Field("PROTOCOL")].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "704": "Closing letter15.pdf", "712": "Closing letter16.pdf" } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource(); By the way, in validation, the rule is always going to return a null resource. That's because it needs the name of the frame (which isn't available at the validation stage) in order to return the resource. If you want to test the value of 'p1' when you're validating your rule, modify the code to look like this: var frameName = (FusionPro.inValidation) ? "p1" : FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3] = [Field("P1"),Field("P2"),Field("P3"),Field("PROTOCOL")].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "704": "Closing letter15.pdf", "712": "Closing letter16.pdf" } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource();
  14. Unfortunately it doesn't look like your zip file contains the .cfg, .def, or .dif files that are generated when you collect your template in FP. Regardless, since I'm running an older version of FusionPro, it wouldn't be much help to me anyway. If you've imported all of your PDFs as resources your return line needs to look like this: return (field) ? Resource(pdfMap[field]) : NullResource(); If you want to add the resources on the fly: return (field) ? CreateResource(pdfMap[field], 'graphic') : NullResource(); This does not go in the OnRecordStart callback. Yes, apply the same graphic rule to each of your frames.
  15. Well I can't say for certain that I really know what you're trying to do. Collecting your template and data file to post to the site would make it easier to help you. At least knowing what version of FP you're using would be pretty insightful. Anyway, what I would do is create a graphic rule and set it to "Re-evaluate this rule for every graphic frame." Then you want to name your various graphic frames by which field they should pull from: "p1", "p2", and "p3" respectively. Your graphic rule would look like this: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3] = [Field("P1"),Field("P2"),Field("P3"),Field("PROTOCOL")].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "704": "Closing letter15.pdf", "712": "Closing letter16.pdf" } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource(); Then apply that rule to each frame. Basically what's happening is I've created an array of your 3 fields "P1", "P2", "P3", and the "PROTOCOL" field. Those values are assigned to variables: 'p1', 'p2', and 'p3'. I filtered out the empty variables so if all values exist for example: var [p1,p2,p3] = ["1","3","4","704"].filter(String); // p1 = 1 // p2 = 3 // p3 = 4 // and protocol is not used If there's no value for Field("P2"), this would happen: var [p1,p2,p3] = ["1","","4","704"].filter(String); // p1 = 1 // p2 = 4 // p3 = 704 I used the frame name to determine which variable the rule should pull the graphic for (p1, p2, or p3) and then use the "pdfMap" to determine which PDF to pull for each variables value. If the variable is null a NullResource is returned as would be the case for p3 in: var [p1,p2,p3] = ["1","","","704"].filter(String); // p1 = 1 // p2 = 704 // p3 = *null*
  16. You could modify the useOverFlow function to return the page number rather than a boolean value: function useOverFlow(frameName){ var text = FindTextFrame(frameName).content; var tm = new FusionProTextMeasure; tm.useTags = true; tm.maxWidth = GetSettableTextWidth(FindTextFrame(frameName)); tm.CalculateTextExtent(text); return (tm.textHeight > GetSettableTextHeight(FindTextFrame(frameName))) ? "Page2" : "Page3"; } Then your SetBodyPageUsage function could be modified to this: FusionPro.Composition.SetBodyPageUsage(useOverFlow("Frame Name"),true); Assuming, as Dan said, both "Page2" and "Page3" are both initially set to false. Or don't modify the function at all and just add a 'pg' variable: var pg = (useOverFlow("Frame Name")) ? "Page2" : "Page3"; FusionPro.Composition.SetBodyPageUsage(pg,true);
  17. Then maybe you should have a rule that returns page 1, 2 and 3 of the PDF onto their respective pages in the template and then use the link I posted to only pull in page 4 through the rest of the pages using an overflow page. You'd only have to modify the for loop to start at 4 rather than 1.
  18. Yeah I figured that was the case and while it seems like I'm griping about it now (I'm really not – I promise), the moment the mag options went missing I'd encounter a scenario that I'd need it. That description is better than "hairy subject" but I can definitely empathize with you there. Oh I see. That makes sense. Thanks! But in all honesty, I just like to post 20 lines of code to see your reply of how to do it in 5. Thanks for sharing your knowledge with the rest of the community!
  19. Well you still need to create the resource. If you're putting the image in a text rule you can do this: return CreateResource(image).content; If you're putting it in a graphic rule: return CreateResource(image); You definitely don't need to have blanks if they aren't required. I would think the easiest way to do this would be to use a text rule, a text frame on your first page and set it to overflow to your second page (an overflow page). See this thread for more details and an example of how to accomplish that.
  20. Sorry, Dan! I didn't you were suggesting the "IsOnlinePreview" function. I've updated my post; however redundant it may be.
  21. I understand that it copyfits proportionally until it hits mins and maxes. The additional code I wrote keeps it from scaling the text out of proportion. The issue that I'm encountering is: once it hits the min/max it's no longer proportional. Increasing the size would work and enlarging the max limit is certainly an option – I'm just giving an example. I'm hesitant to say that specifying the max/min of both the magnification factor and the pointsize seems like too many moving pieces because I'm sure that without the option, I'd want it, but right now, I can't understand why I wouldn't just specify the max/min pointsize and let the function determine the rest. I can't imagine a scenario where I'd say "okay, this can only get 25% smaller" as opposed to saying "okay, this font can't be smaller than 6pt." Anyway, I guess what I was trying to point out is: by default, you can't set the max and min pointsizes and expect the text to remain scaled proportionally should one of those limits be reached. I'm not really sure that's accurate. This block of code suggests that it tries to "rationalize" the parameters so that if the min is larger than the max it switches them: MagnifyAttributes.prototype.rationalize = function() { var i; if (this.min > this.max) { i = this.max; this.max = this.min; this.min = i; } if (this.factormin > this.factormax) { i = this.factormax; this.factormax = this.factormin; this.factormin = i; } } So in the code you posted, the text would never increase past 6pt font. Ultimately, I guess copyfitting text in general is a hairy subject with a lot of "what if" scenarios and while I feel confident that the built in functionality is adequate in most situations, I just wanted to follow up on my original question and throw this make-shift solution out there in case someone else needed this functionality. If nothing else, you can look at this as an Evernote for Future-Ste. Because I know he's pretty forgetful.
  22. If you want to suppress the frame from an online preview, give Dan's suggestion a shot: I'm confused. Do you have a text frame and a graphic frame both named "Cover" now? This should suppress your text frame: FindTextFrame("Cover").suppress = IsOnlinePreview(); If you collect your template (FusionPro > Collect...) and post it to the forum, it might be easier to help diagnose where you're going wrong.
  23. Well, after further investigation and reading through the builtin.js file, I think I was "telling FP to copyfit leading and text" incorrectly. I (mistakenly) set up my OnCopyfit Callback rule to look like this: if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); if (!Copyfit(new MagnifyAttributes("leading", 25, 400, 60, 720))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); There are two things wrong with that (which have become obvious to me now): Calling the Copyfit function twice seems like it would lead to copyfitting the text first and then attempting to copyfit the leading. It seems like the MagnifyAttributes object interprets the min/max limit of leading as points rather than 10th's of a point. While reading through the builtins.js file, I came across this block of code: From function Copyfit // handle an array as the first argument if (arguments.length == 1 && arguments[0] instanceof Array) args = arguments[0]; else { args = Array(); for (i = 0; i < arguments.length; i++) args.push(arguments[i]); } So that means the Copyfit function will accept multiple arguments. Modifying my code to the following applied the same magnify factor to both the leading and the text of my tagged text: if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72),new MagnifyAttributes("leading", 25, 400, 6, 72))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); The one thing to note, I guess, is that 'magnify' tag that gets applied to a frame's content, sets a magnify factor to increase/decrease your text/leading and it also sets a max and min point size for the text/leading. So for example, if I have two lines of text in a large frame set to "fill frame," the first line is larger (60pt) and the second line is smaller (10pt): The 'magnify' tags may have a factor of "400" but since the header (60pt) is pretty close to the max pointsize (72pt) it will only be magnified by 120% while line 2 keeps increasing in size. While I understand the reasoning behind that, some of our clients are very specific about keeping headlines 50% larger than the disclaimer, etc. They want the text to scale proportionally basically. With that being said, I came up with some code that will copyfit a text frame proportionally. Basically, I'm variably figuring out what the upper and lower bounds of the magnification factors should be based on the font sizes used. So, I read in the content, make an array of the font sizes, find the highest and lowest values, and then figure out the upper and lower bounds based on how much they could be magnified before they reach the min/max pointsize. Making my OnCopyfit rule look like this: // default settings var pointsize_min = 6; var pointsize_max = 72; var mag_min = 25; var mag_max = 400; var cf = FusionPro.Composition.CurrentFlow.content; cf = cf.replace(/<variable name="([^"]*)">/g,function(a,b){return RuleOrField(b);}); var keys = ["pointsize", "z newsize"]; var find = '(' + keys.join("|") + ')\\s?=\\s?"?\\d*'; var pointsize = cf.match(new RegExp(find, 'gi')) || []; // Remove dups pointsize = pointsize.filter(function(item, pos) {return pointsize.indexOf(item) == pos;}); // Make them numeric values pointsize = pointsize.map(function(s){s = s.replace(/[^\d]/g,''); return StringToNumber(s);}); // Sort in ascending order pointsize = pointsize.sort(function(a,b){return (a > b) ? 1 : (a < b) ? -1 : 0;}); if (pointsize.length > 1) { var smallest = pointsize[0]; var largest = pointsize[pointsize.length-1]; mag_min = Round((pointsize_min/smallest)*100,0); mag_max = Round((pointsize_max/largest)*100,0); } // If the font's already larger than max, don't allow Copyfit it to increase it mag_max = (largest > pointsize_max) ? 100 : mag_max; // If the font's already smaller than the min, don't allow Copyfit it to shrink it mag_min = (smallest < pointsize_min) ? 100 : mag_min; if (!Copyfit(new MagnifyAttributes("text", mag_min, mag_max, pointsize_min, pointsize_max),new MagnifyAttributes("leading", mag_min, mag_max, pointsize_min, pointsize_max))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); So in my example, Copyfit would now see that the largest font size in the frame is 60pt. Knowing that the max-pointsize is 72, it will set the max-magnification factor to 120 to keep the second line proportional to the first. I admit, I haven't tested this very much but it seems like it should work. Maybe someone will find this helpful. If this is documented somewhere and I missed it, I'll feel pretty stupid but I swear I don't remember reading how to pass Copyfit different attributes anywhere.
  24. Put it in the OnRecordStart callback rule
  25. You're right the '!' negates the returned value of the "FusionPro.Composition.isPreview." If you want to suppress the graphic frame (aka setting the suppress property of the frame to 'true'), you need to remove the exclamation mark: FindGraphicFrame("Cover").suppress = FusionPro.Composition.isPreview; If you're using MarcomCentral (I can't tell since you haven't specified the software you're using) and you want the watermark to show during an online preview, you'll want to adjust the code to be: FindGraphicFrame("Cover").suppress = IsDesktopPreview()
×
×
  • Create New...