Jump to content

ThomasLewis

Members
  • Posts

    298
  • Joined

  • Days Won

    11

Posts posted by ThomasLewis

  1. 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.

  2. 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.

  3. 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.

    • Thanks 1
  4. 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.

  5. 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);
        }
    }

     

    • Thanks 1
  6. 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!

  7. 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")]);

     

  8. 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.

  9. 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);

     

  10. 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.

  11. 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.

  12. 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.

  13. 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.

  14. 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.

×
×
  • Create New...