-
Posts
298 -
Joined
-
Days Won
11
Posts posted by ThomasLewis
-
-
You can do something like this in OnRecordStart to control the visibility of the graphic frame.
FindGraphicFrame("Manager Logo Frame Name").suppress = (Field("TPA Group Field") != "Manager" || Field("Manager Logo") == "No, I don't want the logo.");
You need to name the logo frame and put whatever field you have in there that you mentioned was in the TPAs.
This works by checking if they are not a "Manager" then it will be true and suppressed OR if they choose No then it will be suppressed.
Also, if the managers are part of a Marcom Group you can filter the Yes/No dropdown so that only managers can see the Yes option. With the above rule in place they will still be suppressed for non managers but it will make more sense for them if they can't ever choose Yes to begin with.
-
Did you copy and paste the lines or did you key them in? If you keyed them in you probably put a comma where a semicolon needs to go. Only way to know for sure is if you attach the PDF file.
-
1 hour ago, MartyrSyx said:
Curious. When did "FusionPro.templateFileName" become available? I may have missed it in release notes and the documentation.
Also not listed in the Building Blocks/Objects. Makes you wonder how many other goodies are hidden in there somewhere.
-
Put this in OnRecordStart. Make sure it's enabled. The rule was turned off in sample provided.
for (i = 56; i > Field("Page Qty") * 2; i--) FusionPro.Composition.SetBodyPageUsage(i, false);
-
I am not aware of any way to get the template PDF name. I really wish that was a thing as I could make good use of it myself. Unless someone else knows of some way to do it you pretty much have to hardcode it in.
FusionPro.Composition.outputFileName = "MyTemplateName_" + range + "." + FusionPro.Composition.outputFormatExtension;
-
You have to assign a value to FusionPro.Composition.outputFileName with an =
var iname = GetFileName(PrimaryInputFile()).replace(".csv", ""); var range = CurrentRecordNumber() + "-" + (CurrentRecordNumber() +100); FusionPro.Composition.outputFileName = iname + "_" + range + "." + FusionPro.Composition.outputFormatExtension;
This assumes the input file is a .csv, otherwise change that part.
-
I'm glad you got it worked out. You can simulate the padding with the copyfitting by reducing the width. I had it set to 140 points which is just under 2 inches. If you want to ensure an eighth inch on either side then reduce to 126 or whatever works for you.
One thing that helped me when I started learning FusionPro was printing out the Javascript section of the rules guide, put it in a binder, and just write notes all over it. I also started collecting snippets of code in text files and named them in ways that would help me search them later. I still refer to them every so often even 10 years later.
- 1
-
I'm not sure where that would be coming from unless MarcomCentral is sending some tags along with the text. They way you have it formatted, it would have to be sending something for every single field. If even one on the line is blank the entire line would be omitted. The copyfitting code only effects the pos#Dept fields which isn't enough to change the result if say the pos#StoreNo field was blank, the whole line should omit.
You could try changing the code in OnRecordStart:
change: if (Field(fn)) { to: if (RawTextFromTagged(Field(fn)).length > 10) {
This makes sure its only evaluating non-markup text and if the length is greater than 10, which it would need to be if it needed to be copyfit.
I don't suspect this will make any difference though, as I said, if one of the other fields is blank the whole line should not show.
The other thing you could do, which is a much more aggressive method, is to strip any tags from all the empty field inputs. Add this code above the other code in OnRecordStart:
for (var f in FusionPro.Fields) { if (!Trim(RawTextFromTagged(FusionPro.Fields[f]))) FusionPro.Composition.AddVariable(f, "", false); }
Not sure if any of this will work but it's worth a shot.
-
If you add the following code to an OnRecordStart rule, it will copyfit the pos#Dept fields to fit the 2 inch space. Then you don't need to limit the characters.
for (i = 1; i <= 6; i++) { var fn = "pos" + i + "Dept" if (Field(fn)) { var cf = CopyfitLineWithMagnify(Field(fn), "Brandon Grotesque Regular", 14, 140, false, "textwidth"); FusionPro.Composition.AddVariable(fn, '<span>' + cf + '</span>', true); } }
- 1
-
Worked ok for me. See attached.
-
Wouldn't this be way easier if you just skip the table and setup a center tab at 144pt and a right aligned tab at 288pt?
-
My biggest issue with the FormatPhoneNumber function is when you have a 1 it forces the format to start with +1 . I suppose you could use a replace on it, in this case:
result.push(label.bold() + " " + FormatPhoneNumber(nums[label]).replace("+1 ", "1."));
It is rather annoying though, I wish there was a FormatPhone function that worked more like the FormatNumber one where you can just use something like FormatPhone("1.###.###.####", num).
Also, the .bold() is new to me, apparently its an old deprecated function in javascript, but seems super useful in FusionPro. Thanks for that!
-
These sorts of formats are often pretty specific to each piece. Here's a rule that would work for this one but would need a lot of adjusting if the format changed much.
function format_numbers(label_number) { var output = ""; for (i = 1; i < label_number.length; i += 2) { var n = label_number[i].replace(/\D/g, ""); //remove any formatting from number if (n.length > 6) //check to see if number is present { output += '<b>' + label_number[i -1] + '</b>' + " "; //set bold label + space if (n[0] == "1") //check if number starts with a 1 output += "1."; if (n.length > 7) //check for area code output += n.substr(-10,3) + "."; output += n.substr(-7,3) + "." +n.substr(-4,4); //split number up and add periods if (i < label_number.length -1) //add a seperator space between numbers if its not the last one output += " "; } } return output; } //format as [Label, Number, Label, Number, etc]; return format_numbers(["Direct", Field("Direct Number"), "Mobile", Field("Mobile Number"), "Fax", Field("Fax Number")]);
-
When I extract that zip file and turn on preview it works without any changes. I think the issue is your jpg files don't live in the same directory as your template pdf. You would need to add the full path into the "Search Path" box in the composition window for it to see them.
If this is going to be a product on Marcom it would just be a matter of populating the Graphic dropdown with a Library Collection and you don't have to worry about paths so much. It will just pick up the graphic chosen.
-
Change your data CSV to look like this:
Graphic
02_CPS625_20230329_0036.jpg
05_CPX097_20170808_0049-Edit-2.jpgAlter the line in the javascript from
var my_image = CreateResource("photo.jpg", "graphic", true);
to
var my_image = CreateResource(Field("Graphic"), "graphic", true); -
If you use it in OnRecordStart and set both pages to "unused" by default, you could use it in a way to turn on the page, then push the graphic to the frame, which should be named the same as the page.
function P_or_L(graphic_res) { var tm = new FusionProTextMeasure; tm.CalculateTextExtent(graphic_res.content); if (tm.textHeight > tm.textWidth) return "Portrait"; else return "Landscape"; } var my_image = CreateResource("photo.jpg", "graphic", true); var version = P_or_L(my_image); FusionPro.Composition.SetBodyPageUsage(version, true); FindGraphicFrame(version).SetGraphic(my_image);
-
The only way that I know of to cycle through the same data set multiple times is to read it in as an external data file instead of your input file (which would be "none") and then loop it using repeat record count to build out the PDF. I could try to walk you through it but I think the syntax for external data files has changed since version 7.
-
You can run FusionProTextMeasure on graphics to get a height and width. You might use a function like this:
function image_is_portrait(graphic_res) { var tm = new FusionProTextMeasure; tm.CalculateTextExtent(graphic_res.content); return (tm.textHeight > tm.textWidth); } var my_image = CreateResource("photo.jpg", "graphic", true); return image_is_portrait(my_image);
This would return true if the height is greater than width, ie portrait, or false if landscape.
-
You can do that in the same rule. I don't know how you are evaluating that but it might be something like this:
if (Field("Include Logo") == "No") return ""; else return '<graphic file="logo.pdf" width=7200>';
-
I'm sure you'll have a ton of questions on this. It is not by any means easy or simple. But, I suggest you look over the rule carefully and try to adapt it for your needs. The only way I would be able to troubleshoot is if you post your adapted template.
-
That info isn't really outdated. Just make an empty text rule and put something like this:
return '<graphic file="logo.pdf" width=7200>';
Then include the rule on the line in your text frame.
-
I think you have the answer already in that what they want is not part of the functionality. You can always ask Marcom about custom development.
One workaround might be to set the frame to be a square in the center of the area the logo is to appear. Set it to Proportionate Fill and turn off the clipping icon. This should then check the dpi based on the smaller dimension. The only issue you would run into is if someone uploaded a logo that was extremely wide or tall that would push beyond the boundaries of where you might want. If you can post a generic version of the template it would be a lot easier to come up with a solution.
-
Are you using MarcomCentral? Where is the dropdown coming from?
If it is MarcomCentral, I think you would need what they call iForms to set up the phone numbers for each person. Problem is, they are separate from Profile Attributes, so there's no way for the customer to fill out those dropdowns. You would have to manage that. Another thing that makes this a challenge is hiding the dropdown if the phone number in the attribute is populated. It might just make more sense to make all of them part of the dropdown, including if there is only one number. But again, that isn't something the customer can maintain themselves. I would be on your end only.
-
Is the requirement something on MarcomCentral or something else? You don't really explain what the "it" is in "Can it require".
Regardless, Proportionate Fill is definitely what you want not Best Fit. I don't think support fully understood what you were asking for, which is more about changing how the image limits are handled. If you are using MarcomCentral I think all you can set is DPI. That has little to do with any code you can add in the template. Maybe you can be more specific on how your limits are being imposed on the customer.
Aligning Phones/email based on phone label width
in Formatting Text
Posted
Here's a sample on how to do this adapted for your use. All the rules are in OnRecordStart with some comments on what's going on. It could probably be cleaned up some but I think it should work for your project.
Variable_Tab_Sample.zip