Jump to content

ThomasLewis

Members
  • Posts

    294
  • Joined

  • Days Won

    11

Everything posted by ThomasLewis

  1. 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);
  2. 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;
  3. 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.
  4. 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.
  5. 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.
  6. 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); } }
  7. Worked ok for me. See attached. ID70_RPIS0819R_5x7_CareerPyramidSign Rev.pdf
  8. 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?
  9. 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!
  10. 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")]);
  11. 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.
  12. Change your data CSV to look like this: Graphic 02_CPS625_20230329_0036.jpg 05_CPX097_20170808_0049-Edit-2.jpg Alter the line in the javascript from var my_image = CreateResource("photo.jpg", "graphic", true); to var my_image = CreateResource(Field("Graphic"), "graphic", true);
  13. 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);
  14. 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.
  15. 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.
  16. 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>';
  17. 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. centered text.zip
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. There's 2 ways to do this. The most configurable way is with tables. There's detailed instructions in the Tables section of the user guide under "The FPTable JS Object". Alternatively you could also set them up with inline graphics. Create the line as a PDF and bring it in between paragraph tags using the <graphic> tag.
  23. If you change FusionPro.Composition.SetBodyPageUsage("Location2", Field("Location2")); to FusionPro.Composition.SetBodyPageUsage("Location2", Field("Location2") && !Field("Location1")); that should fix that issue, assuming you want to default to Location1. I'm not sure what you want if there's no phone or cell though.
  24. Some sample data would be helpful, but without seeing anything, this should effectively replace all those if/elses: FusionPro.Composition.SetBodyPageUsage("Location1", Field("Location1")); FusionPro.Composition.SetBodyPageUsage("Location2", Field("Location2")); FusionPro.Composition.SetBodyPageUsage("FrontNoOffice", !Field("Phone")); FusionPro.Composition.SetBodyPageUsage("FrontNoCell", !Field("Cell")); FusionPro.Composition.SetBodyPageUsage("FrontAll", Field("Phone") && Field("Cell")); There is some obvious logic issues though, like what happens if there is no locations or no phone numbers at all? Either way, maybe this will fix it.
  25. I just realized that it's possible your month and day are being reversed by the DateFromString() function. Can you post a sample of how the date appears in your data file?
×
×
  • Create New...