Jump to content

ThomasLewis

Members
  • Posts

    298
  • Joined

  • Days Won

    11

Posts posted by ThomasLewis

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

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

  3. Change the weeks_out variable to how many weeks forward you want the date. This gets a little tricky when the order placed is on a Wednesday, that's what the allow_same_day variable is for. Once you make the rule(s), you can use the Validate button to check the values and play around with what settings work for you.

  4. function set_date(date_string, day_of_week, week_multiplier, same_day)
    {
        var d = DateFromString(date_string);
        var day = (day_of_week +7 -d.getDay()) % 7;
        if (!same_day && !day) day = 7;
    
        return d.setDate(d.getDate() + day + (7 * week_multiplier));
    }
    
    //settings
    var weekday = 3; //sunday = 0, wednesday = 3
    var weeks_out = 0; //change 0 to how many weeks out, ie 6, 12, 18
    var allow_same_day = false; //if false, items ordered on same day will push to following week
    var order_date = Field("Order Date");
    var date_format = "lm d, yyyy";
    
    return FormatDate(set_date(order_date, weekday, weeks_out, allow_same_day), date_format); 

    Give this a shot.

    • Like 1
  5. I think this should do it:

    var begin = Int(Field("Begin").replace(/\D/g, ""));
    var end = Int(Field("End").replace(/\D/g, ""));
    
    var range_between = 5;
    var lines_per_sheet = 20;
    
    var iterate = (FusionPro.Composition.repeatRecordNumber -1) * (lines_per_sheet * (range_between +1));
    var sequence = "";
    var start_number = begin;
    var ending_number = 0;
    
    for (i = 0; i < lines_per_sheet && ending_number < end; i++)
    {
        sequence += "<t>" + (start_number + iterate) + "<t>-<t>";
        
        ending_number = (start_number +iterate +range_between);
        
        if (ending_number > end)
            ending_number = end;
     
        sequence += ending_number + "<br>";
        start_number += (range_between +1);
    }
    
    FindTextFrame("numbers").content = sequence;
    
    FusionPro.Composition.repeatRecordCount = Math.ceil((end -begin) / ((range_between +1) * lines_per_sheet));
    
    if (FusionPro.Composition.repeatRecordNumber == 1)
        FusionPro.Composition.OpenNewOutputFile(Field("Location").replace(/[^A-Za-z0-9 -]/g, "") + "_impo" + "." + FusionPro.Composition.outputFormatExtension);

     

  6. I reworked this a little bit to work with your data file.

    var begin = Int(Field("Begin").replace(",", ""));
    var end = Int(Field("End").replace(",", ""));
    
    var range_between = 5;
    var lines_per_sheet = 20;
    
    var iterate = (FusionPro.Composition.outputRecordNumber -1) * (lines_per_sheet * (range_between +1));
    var sequence = "";
    var start_number = begin;
    
    for (i = 0; i < lines_per_sheet; i++)
    {
        sequence += "<t>" + (start_number + iterate) + "<t>-<t>" + (start_number +iterate +range_between) + "<br>";
        start_number += (range_between +1);
    }
    
    FindTextFrame("numbers").content = sequence;
    
    FusionPro.Composition.repeatRecordCount = Math.ceil((end -begin) / ((range_between +1) * lines_per_sheet));

    Also, if you rename your page frame to "page" you can run the entire data set and get them all in 1 PDF. Just add this to the bottom of the code:

    FindTextFrame("page").content = "Page " + FusionPro.Composition.repeatRecordNumber;

     

  7. It doesn't work because the qr rule has an embedded leading tag. The only way I have been able to get around that is to change the leading to use the magnify tag. 

    Convert your QR rule to javascript. Change the return MakeQRBarcode line to the following:

    var qrcode = MakeQRBarcode(DataToEncode, ProcessTilde,
                 EncodingMode, ErrorCorrectionMode, PreferredFormat,
                 PointSize, NoFontTag, Font);
    
    return '<f name="IDAutomation2D"><magnify type="leading" factor=' + 100 / 1.2 + '>'
                 + RawTextFromTagged(qrcode).replace(/\n/g, '<br>') + '</magnify>';

    If you are for whatever reason using some non-standard global leading setting that's not 120%, change the 100 / 1.2 to whatever that is.

  8. The last line in your sample code works fine for me. It does in fact move the frame down by whatever value is specified by shiftValue10.

    My questions would be, are you using FusionPro Producer or Server? The other versions do not support x and y movement control. If so, are you using hundredths of points?

    Also, why do this with multiple text frames when it seems you could just do it inline in a single frame? It's really hard to tell what you are going for without a visual.

    • Like 1
  9. There's a few different ways to do this with substrings and regular expressions but I think the easiest is to use split.

     

    return Field("Address").split(",")[0];

     

    This splits the string into segments at every comma. [0] is the first part, [1] would be the next, in this case city, then [2] would be state, etc. The only issue would be if the address contained a comma, for instance with an apartment number. That would end up in the next segment.

  10. Looks like there's something interfering with the IDAutomation2D font or it's not loaded. You might check just the QR rule in a new PDF to see if it works normally on it's own, if so then you have some sort of conflict. If it doesn't work, then your font isn't loaded properly.
  11. I think the real issue here is the lack of left and right margins being set in the code. I modified Dan's code to include a copyfit function with the proper margins set and it seems to work great.

     

    function cf(formatted_text_content, frame_width)
    {
    fptm = new FusionProTextMeasure;
    fptm.CalculateTextExtent(formatted_text_content);
    
       frame_width -= 500; //add some padding so content doesn't fill entire width
    
    if (fptm.textWidth > frame_width)
    {
    	var magnify = Math.floor((frame_width / fptm.textWidth) * 100.0);
    
    	return '<span><magnify type="textwidth" factor="' + magnify + '">' + formatted_text_content + '</magnify></span>';
    }
       else return formatted_text_content;
    }
    
    
    // FPTable with Vars - v04 - cat
    //----------------------------------------------------------------
    var font_format = '<f name="BrownStd"><z newsize=12>';
    var symbol = '<superscript>'+"$"+'</superscript>';
    
    var table = new FPTable;
    var col_width = 3499.2;
    
    // Prices
    var col = new Array(10); // col[0] unused; 1-9 used
    for (var i = 1; i <= 9; i++)
    {
       table.AddColumn(col_width);
    
       var num = "0" + i;
       col[i] = cf(font_format + '<b>' + symbol + Field("column" + num + "_DOLLAR") + '<superscript>' + Field("column" + num + "_CENT") + '</superscript></b>', col_width);
    }
    
    //----------------------------------------------------------------
    // Table
    var MinH = 2880;
    
    for (var r = 0; r < 19; r++)
    {
       var row = table.AddRow();
       row.minHeight = MinH;
    
       for (var c = 0; c < 9; c++)
       {
           var cell = row.Cells[c];
           cell.HAlign = "Center";
           cell.VAlign = "Middle";
           cell.Margins = new FPTableMargins; 
           cell.Margins.Top = 0;
           cell.Margins.Bottom = 0;
           cell.Margins.Left = 0;
           cell.Margins.Right = 0;
           cell.Content = col[c + 1];
       }
    }
    
    return table;
    

  12. This should work for you. Just a precaution though, you need to make sure you put that space in between the time and the meridiems.

     

    This works by splitting the time up into 3 sections, the hour, the minutes, and the meridiems.

    This first check is to see if one of the 2 drop downs is not used and just outputs what is there.

    The second checks if the meridiems match, if so it just uses the hour of the first drop down

    Lastly, if both drop downs are used and the meridiems dont match, it outputs the values as is with a hyphen between them.

     

    I have no doubt there is a more succinct way to achieve this, but this should work for what it is.

     

    var dd1_full = Field("Drop Down 1");
    var dd2_full = Field("Drop Down 2");
    
    var dd1_split = dd1_full.split(/[\:\s]/);
    var dd2_split = dd2_full.split(/[\:\s]/);
    
    if (!dd1_full || !dd2_full)
    return dd1_full + dd2_full;
    else if (dd1_split[2] == dd2_split[2])
    return dd1_split[0] + " - " + dd2_full;
    else 
    return dd1_full + " - " + dd2_full;

×
×
  • Create New...