Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Posts posted by step

  1. Trying to return a single bold character in a string. Client wants a bold "F" after the fax number (if there is one.) I can't suppress the whole line when fax is empty, because there are other items on the line. Trying this:

     

     

     

    I have the "Treat returned strings as tagged text" checked, but the F is not coming back bold. Any thoughts? Thanks.

     

    You need to put quotes around your tags:

    
    var fax = Rule("fax_Rule");
    
    if (fax.length > 0) { 
    return fax + " " + [color="Red"]"[/color]<b>F</b>[color="red"]"[/color] ; }
    

    Or:

    var fax = Rule("fax_Rule");
    if (fax)
       return fax + " <b>F</b>";
    

  2. The issue I have, even when copyfit is turned off, is that the text frame that is being converted is 32point in height and the text is only 11 points.

     

    I am trying to keep to the clients design as closely as possible without manually re-positioning text frames. I would prefer to code this particular text frame to only appear as one line of text at 11 point font.

     

    I don't understand why you wouldn't just adjust the text frames so that they won't wrap. If you always want the text to start at a specific Y-coordinate, what's the point of vertically centering something? You could just vertically align your text frames to the top, reduce the height of the text frame and voila – your text is truncated to one line.

     

    My other option is to determine the exact height and position of the text frame to prevent any tiny shift in the text position that occurs because a new line of text is introduced and tries to shift to align to the top, since the all text is not able to align center vertically.

    Again, I think you're really over-thinking this one. Why stress over coding a solution that could be fixed by making a few tweaks to the text frame.

  3. There may be an easier way to accomplish this, but you could probably get the results you want by using linked text frames and the "verticalstart" attribute of the paragraph tag.

     

    You'd create a rule that returned the content of both pages joined by a paragraph tag that forces the contents of the back page to start at the top of the "next page". If the contents of the front page overflows onto the second page, starting the back contents on the "next page" effectively tells the text to overflow to a 3rd linked frame and since a 3rd linked frame doesn't exist, the text won't fit.

     

    So, we can modify the OnCopyfit rule to check whether or not the text fits. If it fits, we can assume that the front page did not need to overflow to the second page, if it doesn't fit, we need to remove the "verticalstart" attribute from the paragraph tag so that it will fall inline with the overflowed text.

     

    Here's an example:

    Text Rule:

    var spaceBetweenParagraphs = 1000; // 1000 = 10 pts
    var front = 'Tofu palo santo bespoke kombucha, leggings health goth prism VHS everyday carry adaptogen actually asymmetrical iPhone single-origin coffee. Tote bag subway tile gochujang cliche schlitz tattooed XOXO, succulents edison bulb hella. Tote bag banjo iPhone, actually selvage fixie gochujang hell of retro palo santo taxidermy keytar microdosing ethical normcore. Next level ennui truffaut taiyaki, food truck chartreuse you probably haven\'t heard of them iceland. Enamel pin kickstarter meditation locavore. Actually lo-fi succulents, dreamcatcher slow-carb cray viral activated charcoal gochujang irony af palo santo meggings tofu. Bushwick celiac keytar, affogato chia pour-over semiotics artisan chicharrones cold-pressed.'
    
             // Uncomment paragraphs below to demonstrate inline back page.
             // + '<p leadbefore="' + spaceBetweenParagraphs + '">Humblebrag yuccie craft beer semiotics sartorial forage pork belly polaroid, distillery hoodie. Neutra activated charcoal cronut quinoa pickled, whatever occupy. Humblebrag ramps tumeric forage, messenger bag meditation 90\'s synth. Kickstarter pork belly deep v, raw denim activated charcoal vaporware synth. Umami cornhole hoodie, live-edge letterpress small batch hella vexillologist. Af venmo food truck fap, plaid cardigan edison bulb tilde. Art party tofu health goth vaporware sustainable.'
             // + '<p leadbefore="' + spaceBetweenParagraphs + '">PBR&B beard pitchfork, bushwick tumblr meggings blue bottle man braid pop-up la croix aesthetic tote bag post-ironic yr. Selfies intelligentsia poke plaid, pinterest live-edge tattooed banjo typewriter flannel photo booth bitters drinking vinegar. Tumblr meggings lyft authentic, raw denim af biodiesel 3 wolf moon semiotics banh mi health goth squid. Copper mug offal sartorial hell of gentrify, air plant kinfolk crucifix adaptogen austin affogato la croix. Tumeric live-edge tacos literally williamsburg, DIY roof party raw denim cardigan jianbing irony austin deep v. Quinoa kickstarter church-key, schlitz raclette stumptown gluten-free ugh mlkshk neutra helvetica tattooed small batch. Intelligentsia stumptown hashtag, cronut wolf pinterest YOLO 90\'s taxidermy VHS wayfarers tattooed raw denim franzen master cleanse.'
             // + '<p leadbefore="' + spaceBetweenParagraphs + '">Coloring book salvia health goth wayfarers edison bulb, church-key actually you probably haven\'t heard of them tote bag beard twee chillwave 3 wolf moon hoodie. Farm-to-table locavore roof party cray. YOLO banjo man braid ugh cloud bread. Microdosing everyday carry cred, mixtape master cleanse hexagon snackwave you probably haven\'t heard of them kombucha gentrify chicharrones bicycle rights ugh fixie letterpress. Enamel pin poke letterpress, pour-over prism mixtape echo park kickstarter hexagon artisan copper mug offal blue bottle crucifix. Palo santo microdosing blog, ethical irony lomo single-origin coffee swag hashtag raclette farm-to-table blue bottle selfies master cleanse chartreuse. Leggings lo-fi yuccie, lyft umami mustache polaroid snackwave celiac.'
    
    var back = 'Literally chartreuse master cleanse, tilde glossier locavore put a bird on it VHS succulents celiac craft beer. La croix direct trade readymade organic mixtape, kitsch 8-bit blog iPhone try-hard live-edge slow-carb. Flexitarian polaroid forage cold-pressed, occupy poutine portland tacos vice gastropub. Everyday carry dreamcatcher health goth next level neutra kombucha, heirloom tousled affogato pork belly retro. Irony chambray occupy, gastropub keytar woke four loko butcher ugh vinyl tumeric umami man bun lumbersexual edison bulb. Literally ethical readymade activated charcoal, knausgaard PBR&B mixtape small batch hashtag woke. Blue bottle readymade semiotics, jianbing fashion axe keytar craft beer plaid keffiyeh lyft actually iPhone 8-bit.';
    return [front, back].filter(String).join('<p verticalstart="topofpage">');
    

     

    OnCopyfit:

    var cf = FusionPro.Composition.CurrentFlow;
    // If it doesn't fit, don't start back page at "topofpage"
    if (!cf.fits)
       cf.content = cf.content.replace(/<variable name="([^"]+)">/g, function(s,p) {
           return RuleOrField(p).replace('verticalstart="topofpage"', '');
       });
    // Regular Copyfitting...
    if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
       ReportWarning("Could not copyfit text in flow " + cf.name);
    

  4. Yeah, JavaScript is classically used to interact/manipulate with the DOM in a web browser. Obviously, since FusionPro is not executed within the context of a web browser, there will be some differences between the code found on this forum and a generic JS related article found on the internet. That said, the syntax of the actual JavaScript code are the same across both.

     

    The main difference is that FusionPro has supplied built-in functions and methods that allow you to interact with the FP plugin. The "Field" function, the "FusionPro.Composition.SetBodyPageUsage" method, etc are specific to FusionPro and won't be found in an Angular app (for example). The "Functions" and "Objects" tabs of the "Building Blocks" dialog window define what most of those built-in functions do. But, if you're ever unsure of how a snippet of code found on this forum works, you should feel free to ask.

  5. Yes, the original script you posted returns an array – the elements within the array are separated by a comma when output. The join method joins the elements with something other than a comma and converts the returned element to a string.

     

    So, in your second snippet, you're joining the element with a tab tag. But you could join them with a break tag (<br>) like in the original script, or a space, or any ole' string you want, really:

    var cellImg = Resource("cell").content;
    var voiceImg = Resource("voice").content;
    var faxImg = Resource("fax").content;
    var emailImg = Resource("email").content;
    
    var numbers = [
       [Field('EMAIL'), emailImg],
       [Field('PHONE'), voiceImg],
       [Field('CELL'), cellImg],
       [Field('FAX'), faxImg]
       ].filter(function(s){return s[1]}).map(
           function(s){
               return '<p br=false superoffset=70 superratio=100>' + s[1] + '<superscript> ' + s[0] + '</superscript>';
       })
    
    return numbers[color="Red"].join("any ole' string you want");[/color]
    

  6. I think you want to do something like this:

    var logoField = Field("logo"); // Your logo field
    var logos = {
     A:[ // Logos that use frame "A"
       ],
     B:[ // Logos that use frame "B"
         "sports medicine.pdf",
         "neurosurgery.pdf",
         "pain management.pdf",
         "primary care.pdf"
       ],
     C:[ // Logos that use frame "C"
       ]
    };
    
    for (var frame in logos)
     FindTextFrame(frame).suppress = logos[frame].indexOf(logoField) === -1;
    

  7. Hello all,

     

    I'm hoping someone can point me in the right direction. Like the previous poster, I'm having an issue with the VAlign property of FPTable. I have a rule in which I create a table and set it to align cell content to center, both horizontally and vertically. This works if I call the rule as the first item in a text box. But if there is anything at all, even just a carriage return, above the rule, the content of the cells floats to the top. Everything else looks to be following the rule.

     

    Here is the rule:

    new FPTable;
    var myTable = new FPTable;
    myTable.AddColumns(16000, 6000, 6000, 6000, 6000, 6000);
    
    // Add the top row
    var topRow = myTable.AddRow();
       topRow.Cells[0].HAlign = "Center";
       topRow.Cells[0].VAlign = "Middle";
       topRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left");
       topRow.Cells[0].Font="Times New Roman";
       topRow.Cells[0].PointSize=11;    
       topRow.Cells[0].Bold="On";
       topRow.CopyCells(0,1,2,3,4,5);
       topRow.SetContents("Your Monthly Amount", "$100", "$250", "$500", "$1,000", "$5,000");
    
    // Add the bottom row
    var bottomRow = myTable.AddRow();
       bottomRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left");
       bottomRow.Cells[0].ShadeColor="Black";
       bottomRow.Cells[0].ShadePct=15;
       bottomRow.Cells[0].Font="Times New Roman";
       bottomRow.Cells[0].PointSize=11;
       bottomRow.Cells[0].Bold="On";    
       bottomRow.CopyCells(0,1,2,3,4,5);
       bottomRow.SetContents("Our Offer To You", "100", "250", "500", "1000", "5000");
    
    // Center the table in the text box
    return myTable.MakeTags().replace(/^\<table/, "<table alignment=center");

     

    Using FP VDP Creator 8.2.7. I've attached a sample job for perusal. I cannot seem to figure this one out.

     

    Thanks!

    I understand this is a relatively old post, but I've been battling this bug all week and thought I'd share another workaround. I've noticed in the past that toggling "use legacy line leading" will sometimes remedy the issue (as previously noted in this thread) but I'm still unclear as to why that is. Furthermore, I think FusionPro has begun to rework the way it handles leading – so relying on "legacy" leading as a workaround did not sit well with me.

     

    While thumbing through the section on tables in the TagsRefGuide, I noticed a "space" attribute and found that if you define space above (or below) the table, all of the cells magically become centered again:

    var myTable = new FPTable;
    myTable.AddColumns(16000, 6000, 6000, 6000, 6000, 6000);
    
    // Add the top row
    var topRow = myTable.AddRow();
       topRow.Cells[0].HAlign = "Center";
       topRow.Cells[0].VAlign = "Middle";
       topRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left");
       topRow.Cells[0].Font="Times New Roman";
       topRow.Cells[0].PointSize=11;    
       topRow.Cells[0].Bold="On";
       topRow.CopyCells(0,1,2,3,4,5);
       topRow.SetContents("Your Monthly Amount", "$100", "$250", "$500", "$1,000", "$5,000");
    
    // Add the bottom row
    var bottomRow = myTable.AddRow();
       bottomRow.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left");
       bottomRow.Cells[0].ShadeColor="Black";
       bottomRow.Cells[0].ShadePct=15;
       bottomRow.Cells[0].Font="Times New Roman";
       bottomRow.Cells[0].PointSize=11;
       bottomRow.Cells[0].Bold="On";    
       bottomRow.CopyCells(0,1,2,3,4,5);
       bottomRow.SetContents("Our Offer To You", "100", "250", "500", "1000", "5000");
    // Center the table in the text box
    return myTable.MakeTags().replace(/^\<table/, '<table [color="red"]space="above:1"[/color] alignment=center');
    

    If you actually want to add space above/below the table, then it's worth mentioning that the value should be in 10ths of a point but any value greater than 0 fixes the alignment issue. More info can be found on page 56 of the TagsRefGuide.pdf

  8. Step,

    Would that work for all the file names? This is a list of all the file names that I would need to compose to the correct folders:

     

    20170405A_STD_DM_1-50000-.txt

    20170405A_STD_DM_50001-100000-.txt

    20170405A_STD_DM_100001-150000-.txt

     

    Would it work for when the file name changes to a B after the run number? We alternate weeks from A to B on an 8 week cycle.

    Yes, it would work for all of those scenarios. Here's a breakdown of what I mean by "splitting the input file name at the underscores" that may make it easier to visualize:

    var input = PrimaryInputFile(); // /path/to/20170405A_STD_DM_1-50000-.txt
    input = GetFileName(input);     // 20170405A_STD_DM_1-50000-.txt
    input = input.split('_');       // [  '20170405A',     <--- input[0]
                                   //    'STD',           <--- input[1]
                                   //    'DM',            <--- input[2]
                                   //    '1-50000-.txt']; <--- input[3]
    

    As you can see, when the file name is split at the underscore, the first position in the resulting array (input[0]) will be the correct run number regardless of whether an A or B is used since it simply takes everything up until the first underscore as that value.

     

    The only issue I see is that all our data file names don't have the same number of input slots.

    I don't know what that means.

  9. You don't need to use regexp matching for this. Why not just split the input file name at the underscores?

    var input = GetFileName(PrimaryInputFile()).split('_');
    FusionPro.Composition.outputFileFullPathName = 'D:\\FPDirect\\Submitted\\RUN ' + input[0] + '\\' + input[0] + '_' + input[2] + '_ALL\\' + ReplaceFileExtension(input.join('_'), FusionPro.Composition.outputFormatExtension);
    

  10. I've found a few things in the forum about this, but no clear answer. I'm trying to mark the piece when the Tray Number changes on a postcard mailing so Bindery can quickly see where the next tray begins.

    No clear answer? I thought I was pretty clear in my answer to a very similar question in this thread. The only difference is that you want to insert an extra page when the tray number changes and the original poster wanted to insert an extra page when the stack height hit 100.

     

    I've tried using this in OnRecordStart:

     

    if (FieldChanged("TRAYNUMBER"))

    FusionPro.Composition.SetBodyPageUsage("Break", true);

     

    This does not work when used with FPImposer. I get messages like this in the log file:

     

    "Composing record #12, input record 918

    Sheet #5, record #4

    The number of pages in this record does not match the imposition signature: 2 blank pages will be added.

    A body page does not have master page assigned."

     

    If I compose the file without imposition it works, BUT marks the second piece of the new tray (!?)

    The error you're getting is because the FP imposition you've defined is for 1 page per record but when the tray number changes you're trying to compose 2 pages per record (your postcard page and your "break" page). Instead, you need to change your logic to repeat the record twice when the tray number changes – once with the "break" page enabled (and postcard page disabled) and once with the postcard page enabled (and "break" page disabled). That will give you the results you're looking for while still conforming to the imposition you've defined for FusionPro.

     

    This assumes that the "postcard" is on a body page named "postcard":

    FusionPro.Composition.SetBodyPageUsage("Break", false);
    if (FieldChanged("TRAYNUMBER")) {
     FusionPro.Composition.repeatRecordCount = 2;
     FusionPro.Composition.SetBodyPageUsage("Break", FusionPro.Composition.repeatRecordNumber%2 == 1);
     FusionPro.Composition.SetBodyPageUsage("postcard", FusionPro.Composition.repeatRecordNumber%2 == 0);
    }
    

  11. The problem is that when FusionPro preprocesses the job, the "processedRecordNumber" is zero-indexed (the first record is 0) but when it composes the job the first record is "1". FusionPro preprocesses the job to determine how to layout the records on the imposition you've defined for the job. So on the first record (record 0 during preprocessing) it checks the 'versions' object for the version and adds it. Then on the second record (record 1 during preprocessing), it resets the 'versions' object, checks for the version and determines that record 2 should also print even though they're the same version.

     

    Ultimately, the issue is that FP gets confused when the layout determined during preprocessing doesn't match what the template is saying should print during composition.

     

    The fix is to only reset the 'versions' object if FusionPro is done preprocessing:

    if (FusionPro.Composition.processedRecordNumber == 1[color="Red"] && !FusionPro.Composition.inPreprocessing[/color])
     versions = {};
    
    var isProof = true;          // false to compose job normally
    var version = Field("list"); // Field that indicates version
    if (isProof) {
     if (!versions[version])
       versions[version] = 0;
     FusionPro.Composition.composeThisRecord = ++versions[version] <= 1;
    }
    

  12. function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return n + (s[(n-20)%10] || s[n] || s[0]);
    }
    MyDate = DateFromString(Field("f123_DueToRenewDateString")) ;
    return FormatDate(MyDate, "lm d").replace(/(\d+)$/, getOrdinal);

     

    That doesn't have the year in it, either so I'm not sure why you're seeing the code reflect the year.

     

    function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return n + (s[(n-20)%10] || s[n] || s[0]);
    }
    MyDate = '5/13/17'; 
    return FormatDate(MyDate, "lm d").replace(/(\d+)$/, getOrdinal); // May 13th
    

     

    s there a way to superscript the ordonial? With a tag? </superscript>

    Yes, you can use the 'superscript' to superscript the ordinal:

    function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return n [color="Red"]+ '<superscript>'[/color] + (s[(n-20)%10] || s[n] || s[0])[color="red"] + '</superscript>'[/color];
    }
    MyDate = DateFromString(Field("f123_DueToRenewDateString"));
    return FormatDate(MyDate, "lm d").replace(/(\d+)$/, getOrdinal);
    

     

    The below gives the you flexibility to add the year if you choose:

    function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return s[(n-20)%10] || s[n] || s[0];
    }
    MyDate = DateFromString(Field("f123_DueToRenewDateString"));
    return FormatDate(MyDate, 'lm d') + '<superscript>' + getOrdinal(MyDate.getDate()) + '</superscript>'
         // + ' ' + FormatDate(MyDate, 'yyyy'); // Uncomment to include year.
    

  13. Please paste the code you're using. You've obviously changed it from what you originally posted since the 'FormatDate' function originally just output the month and day.

    function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return n + (s[(n-20)%10] || s[n] || s[0]);
    }
    MyDate = DateFromString(Field("f123_DueToRenewDateString")) ;
    return FormatDate(MyDate,[color="Red"] "lm dd"[/color]).replace(/(\d+)$/, getOrdinal);
    

  14. Or you can do this without naming the pages:

    var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length + 1;
    FusionPro.Composition.SetBodyPageUsage(activeFields, true);
    

     

    True – assuming that the first page in your template has 0 active fields, the second page has 1 active field, etc and if the card has a back it is the last page in the template.

  15. You could try using a 2 column table with a blue border set on the right side of the first column:

    var numbers = [
     ['o', Field("Office")],
     ['e', Field("Extension")],
     ['f', Field("Fax")],
     ['c', Field("Cell")],
     ['', '1835-A Forest Drive<br>Annapolis, MD 21401']
    ].filter(function(s){ return s[1] });
    
    var table = new FPTable();
    table.AddColumns(0.5 * 7200, 2 * 7200); // Left column is .5", right column is 2"
    numbers.forEach(function(num) {
     var row = table.AddRow();
     row.Cells[0].SetBorders('Thick', 'Blue', 'Right');
     var [abbreviation, number] = num;
     if (abbreviation)
       abbreviation = '<color name="Orange">' + abbreviation + '</color>';
     row.SetContents(abbreviation, number);
    });
    return table.MakeTags();
    

  16. I grabbed an ordinal function from this post and modified it slightly (the v variable isn't necessary since a date will never be higher than 31 – much less 100). Then I just replaced the date with the returned value from the getOrdinal function for the matched date:

     

    function getOrdinal(n) {
     var s = ["th","st","nd","rd"];
     return n + (s[(n-20)%10] || s[n] || s[0]);
    }
    MyDate = DateFromString(Field("f123_DueToRenewDateString")) ;
    return FormatDate(MyDate, "lm dd").replace(/(\d+)$/, getOrdinal);
    

  17. I may have a solution for the barcode itself. But I need to make the human readable number underneath in chunks of 4 digits - example:

     

    92148901066154000105004961

     

    Has to appear as

     

    9214 8901 0661 5400 0105 0049 61

     

    under the barcode. The number of digits in this number can vary so it is not always the same number of digits.

    var barcode = '92148901066154000105004961';
    return barcode.match(/(\d{1,4})/g).join(' ');
    

  18. Have you tried removing the position="afterline" attribute? I don't think it's necessary.

    {
       FusionPro.Composition.SetBodyPageUsage("First", true)
       FusionPro.Composition.SetBodyPageUsage("Last", true)
    var path = "c:/SpecBen/staticPDF/";
    var fileName = Field("Product Name") + ".pdf";
    var file = CreateResource(path + fileName,'graphic');
    var pages = file.countPages;
    var result = "";
    
       for (var i = 1; i<=(pages-1); i++){
       result += '<graphic file="' + file.name + '" pagenumber=' + i + ' [color="Red"]position="afterline"[/color]>';
       result += '<P>';
    }
    
    result = result.replace(/.{3}$/,'');
    
    FindTextFrame('graphic').content = result;
    FindTextFrame('graphic_last').content = '<graphic file="' + file.name + '" pagenumber=' + pages + '[color="red"] position="afterline"[/color]>';
    }    
    

     

    By the way, the code in your template is quite repetitive and could be made more concise if you want:

    var firstPage = 'First';
    var lastPage = 'Last';
    var firstGraphic = 'graphic';
    var lastGraphic = 'graphic_last';
    
    var isUpload = /Upload/.test(Field("Product Name"));
    var path = "c:/SpecBen/" + (isUpload ? "uploadPDF" : "staticPDF") + "/";
    var fileName = (isUpload ? Field("Order Number") + "-" + Field("SKU") : Field("Product Name")) + ".pdf";
    var result = [];
    
    if (Field("Product Name") == "Coverage Change Form") {
     firstPage += 'L';
     lastPage += 'L';
     firstGraphic += '2';
     lastGraphic += '2';
    }
    
    //Print an address page at beginning of each order
    if (FieldChanged("Order Number"))
     FusionPro.Composition.SetBodyPageUsage("address", true);
    
    FusionPro.Composition.SetBodyPageUsage(firstPage, true);
    FusionPro.Composition.SetBodyPageUsage(lastPage, true);
    var file = CreateResource(path + fileName, 'graphic');
    var pages = file.countPages;
    
    for (var i = 1; i < pages; i++)
     (file.pagenumber = i) && result.push(file.content);
    
    file.pagenumber = pages;
    FindTextFrame(firstGraphic).content = result.join('<p>');
    FindTextFrame(lastGraphic).content = file.content;
    

×
×
  • Create New...