rjhansen Posted February 24, 2015 Share Posted February 24, 2015 I'm new to FusionPro. I'm trying to create a simple rule using Drag and Drop. I have a series of numbers (1-100) printing on cards. I want the single digit numbers to be a larger font size than the double digit numbers. My data file only has one field, "TableNo". I have the following: If "Numeric value of" "TableNo" (my field) is less than "10" Then Return "FusionProRuleWizard.Action.Change Point Size" I'm specifying 250 pts for the point size change. When I try to insert the rule, the rule itself is printing on the page with the data and is not changing the font size as expected. I've looked at at the documentation and searched the forums but haven't been able to figure out what I'm doing wrong. Quote Link to comment Share on other sites More sharing options...
FreightTrain Posted February 25, 2015 Share Posted February 25, 2015 rjhansen, Drag and drop is probably not the best way to accomplish this. Try an empty rule with the content below. if (Field("TableNo") < "10") return '<z new size="250">'+Field("TableNo"); else return Field("TableNo"); 2 important things to remember: Make sure you check the box at the top of the rule menu for "Treat return strings as tagged text".When you insert the rule the font size should be the desired size for everything > 10. Quote Link to comment Share on other sites More sharing options...
step Posted February 25, 2015 Share Posted February 25, 2015 I agree that this would be easier to accomplish through a custom rule, but I think the rule as it stands is comparing a string to a string which seems like it would throw off the comparison between the two numbers. I think you probably want to re-write the if statement condition (first line) to be: if (StringToNumber(Field("TableNo")) < 10) Quote Link to comment Share on other sites More sharing options...
tobarstep Posted February 25, 2015 Share Posted February 25, 2015 I've never used the drag and drop before, but I whipped up a quick sample and it worked as intended. I'm attaching a jpg screenshot of what my rule looked like in the drag and drop editor window (my field name was "Qty_S" and I used 25pt font, but you get the idea). After I saved the rule I inserted it into a text frame and it worked fine. Incidentally, if you put in the rule that way and then click the button to convert the rule to JavaScript you get essentially the combination of what users FreightTrain and step posted. Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 25, 2015 Author Share Posted February 25, 2015 Thanks for all the input! Definitely very helpful, but I'm still having issues getting this to work. Straight off, using FreightTrain's code didn't change the point size. I suspected I needed the StringToNumber function, but I was calling it wrong. Step's suggestion showed the correct usage, but my rule still didn't work correctly. Then I tried recreating tobarstep's Drag And Drop rule. This didn't change my point size either. Then I converted that to JavaScript and made a couple of changes and now I've got something that changes the point size on 1-9 (as expected) but it also prints the same digit at the original point size right beside the larger number. Here's the rule: if (StringToNumber(Field("TableNo")) < StringToNumber("10")) { return "<span pointSize=230>" + TaggedDataField("TableNo") + "</span>"; } return ""; And a screenshot of the first record as it previews with this rule inserted: http://forums.pti.com/picture.php?albumid=20&pictureid=34 Quote Link to comment Share on other sites More sharing options...
step Posted February 25, 2015 Share Posted February 25, 2015 It sounds like your text frame is returning your rule as well as the variable. You should set the contents of your text frame to only return the contents of the rule and the change your rule to: if (StringToNumber(Field("TableNo")) < 10){ return "<span pointSize=230>" + TaggedDataField("TableNo") + "</span>"; } else { return TaggedDataField("TableNo"); } Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 25, 2015 Author Share Posted February 25, 2015 Thanks Step, I suspected the same thing, but can't figure out how to fix that. Unfortunately, your suggested revision yields the same result. Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 25, 2015 Author Share Posted February 25, 2015 Step, you said "You should set the contents of your text frame to only return the contents of the rule…" How do I do that? Quote Link to comment Share on other sites More sharing options...
step Posted February 25, 2015 Share Posted February 25, 2015 Can you collect your template and post it to the forum with the data? It's really difficult to figure out the problem without seeing all of the factors that come into play. Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 25, 2015 Author Share Posted February 25, 2015 Here's my files.TableNos.zip Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 25, 2015 Author Share Posted February 25, 2015 I made another change which is reflected in the file I just uploaded. Still not fixing the problem. Quote Link to comment Share on other sites More sharing options...
step Posted February 26, 2015 Share Posted February 26, 2015 Sorry, I probably should have specified that by "collect" I meant to select "Collect.." from the "FusionPro" menu. Without doing that, your rules didn't come over. Regardless, I've attached an example in which I've got my code working as I would expect it to. Another way to accomplish what I think you're trying to accomplish would be to insert the "TableNo" variable into your text frame and apply Copyfitting to it (click on the text frame and select "Overflow" from the text pallet). From there you'd select "adjust text to fit" and "allow text to expand to fill." Doing this will create an "OnCopyfit" call back rule that would look something like this: if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72))) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); The "25" is the lowest magnification factor it will apply to your text to get it to fit. The "400" is the max. So it will magnify your text a maximum of 400% the original pointsize in order to get the text to fill the frame. The last two numbers are the min and max (respectively) pointsize the function is allowed. So, by default, Copyfit will only increase the size of the text to 72pt. You can change that parameter to "250" and then there's no need for any rule.122348 Speakers Ball Table Tent Numbers.zip Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 26, 2015 Author Share Posted February 26, 2015 Step, Thanks, that does exactly what I want it to do. I will have to look at the rule you made when I get a chance to see what the problem with mine was. And thanks for the info on the copy fitting. I played with that a little bit when my rule wasn't working but was having trouble getting it to do what I wanted. Your explanation should help me figure out how that works. I really appreciate your time and help with this. Quote Link to comment Share on other sites More sharing options...
rjhansen Posted February 26, 2015 Author Share Posted February 26, 2015 I was missing "TaggedDataField("TableNo")". I had "Field("TableNo") which is why my field was getting dropped in twice. Again, thanks for all the help. 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.