Jump to content

ScottHillock

Registered Users - Approved
  • Posts

    96
  • Joined

Posts posted by ScottHillock

  1. I would suggest this:

     

    var email = 'first.middle.last@whatever.com';
    
    if (!email){return "";} 
    
    //remove all text after @ symbol, then split into an array based on periods
    names = email.replace(/@.*/, '').split('.');
    
    //replace first letter with upper, and concat with the rest of the string 
    for (i = 0; i < names.length; i++){
       names[i] = ToUpper(names[i][0]) + names[i].substring(1);
    }
    
    //join back names with a period separator and add domain
    return names.join('.') + "@CassiaLife.org";

     

    You could also do the following:

     

    var email = 'first.middle.last@whatever.com';
    if (!email){return "";} 
    
    return email.replace(/@.*/, '').replace(/(^|[.]+)([a-z])/g, function (m, $1, $2) {
       return $1 + $2.toUpperCase();
    }) + "@CassiaLife.org";

     

    But, it's harder to adjust in case you wanted to make the names proper case, or remove spaces, etc.

  2. I don't have any experience with Producer. I assumed we were talking about Creator.

     

    The path name is going to be different than if it were on a Mac. I believe you'll need to have the share mapped to a drive and use "Z:\\ABOTA\\"

     

    I'm sure there's some other way with string replacement to always get the jobs to go to your intended folder, but I don't have access to the documentation. This might be a case where you need to contact support.

  3. Looks like the actual path you need is /Volumes/Jobs/ABOTA/

     

    The smb://... is just the server address and not it's location in relation to the filesystem.

     

    FusionPro.Composition.outputFileFullPathName expects a full path and file name.

     

    And FusionPro.Composition.OpenNewOutputFile will output a file in the destination folder from the composition settings. I'm not too sure if these can be mixed. Dan Korn might be able to give more information.

     

    Unless you're specifically trying to move different PDFs to different folders I'm not sure why you're trying this method though. Couldn't you just do the OpenNewOutputFile and point your composition output to the folder you want?

     

    Edit:

     

    Looks like you could just do:

    if (FieldChanged("Member No")){
    FusionPro.Composition.OpenNewOutputFile("/Volumes/Jobs/ABOTA/" + Field("Member No") + "." + FusionPro.Composition.outputFormatExtension);
    }

  4. Couple of things. First when making a post with code use the advanced editor, or use this:

    [code] --- Code goes here --- [/code]
    

     

    Second, does that path "/Volumes/smb/192.168.200.72/Jobs/ABOTA/" even exist? If you open Finder and from the menu bar choose Go > Go to Folder... and then paste that in does it take you to the folder you're expecting?

  5. On your VARIABLE8 you're missing the Field part. Also, I'm not sure if it might have slipped your mind, but in your if statement there needs to be a condition on each pair. So, just having the == "" on the last pair doesn't apply to all of them. But, if you're just looking to see if the field contains anything then you're ok, unless those fields might include a 0. Also, it's composeThisRecord and not ComposeThisRecord. You don't really need the else statement either.

     

    Might also just be personal preference, but I'm not a fan of the multiple if checks. But, here is how I would do it.

     

    var arr = [
    Field("VARIABLE1"), 
    Field("VARIABLE2"), 
    Field("VARIABLE3"), 
    Field("VARIABLE4"), 
    Field("VARIABLE5"), 
    Field("VARIABLE6"),
    Field("VARIABLE7"),
    Field("VARIABLE8"),
    Field("VARIABLE9"),
    Field("VARIABLE10"),
    Field("VARIABLE11"),
    Field("VARIABLE12"),
    Field("VARIABLE13"),
    Field("VARIABLE14")
    ];
    
    var combined = arr.filter(String).join("");
    
    if(combined === ""){
     FusionPro.Composition.composeThisRecord = false;
    }
    
    

  6. I believe you have the order of your parameters switched on your percentage example.

     

    With replace the first parameter is what you are searching for, and the second is what to replace it with.

     

    Here's a bit of code that covers both $ and %:

     

    var fieldName = Field("field");
    
    var field = fieldName.replace(/\$/g,'').replace(/\%/g,'');
    
    if(fieldName.indexOf('$') > -1){return '$' + field;}
    if(fieldName.indexOf('%') > -1){return field + '%';}
    
    return field;

  7. Dan, sample files attached.

     

    Unchecking the Limit processing to.. checkbox does make the notdef character not appear. And it's a viable solution. But, I usually leave that checked to make sure the data source doesn't contain characters that might cause issues on output. But, I should probably move that "checking" to a different workflow process.

     

    We do have FusionPro 9, so the <hkeep> and AddTextReplacement aren't available to us to use yet, but we're looking at the upgrade to 10 in the near future.

    Archive.zip

  8. Excellent Dan, thank you. I'll keep in mind the <hkeep> tags when I need them.

     

    The   character accidentally shows up sometimes in FusionPro text frames when the InDesign source document has returns with a normal space on an empty line. So ^p ^p ends up turning into ^p ^p.

     

    I have a few InDesign scripts to clean things up for FusionPro but on some documents we can't run the scripts, so I was looking for an automated solution to fix the notdef character from basically ever showing up in a document with a   character.

  9. I'm looking to create a rule that will replace all occurrences of a string of text, even when that text is not part of a rule.

     

    Specifically we're having an issue where the notdef symbol is being inserted when some fonts don't have the   character. I'd like to replace the font for this character to one which does have the   glyph defined.

     

    I know how to make this change when the text is returned from a rule. I'm just looking for the FusionPro way of searching through all text frames and replacing characters.

  10. Replacing the repetition of it with a loop, and a join.

    var Strline = [];
    for (i=1; i <= 16; i++){
    Strline[i] = (!Field("series_" + i)) ?" ": Trim(Field("series_" + i) + "<br>");
    }
    
    return Strline.join("");

     

     

    Replacing even more with a filter and adjusting the join.

    var Strline = [];
    for (i=1; i <= 16; i++){
    Strline[i] = Trim(Field("series_" + i));
    }
    
    return Strline.filter(String).join("<br>");

     

    I'm sure there's ways to make it even simpler. But, I tend to leave code a little more verbose.

  11. I think you're trying to use repeatable templates. Which might be beneficial in this project, but I would do them in reverse, with the address block being the repeatable template, and create a new page for each version of the postcard.

     

    Simply add pages and name them the version code, and set the page to unused. Create a OnRecordStart rule to activate the necessary page

     

    FusionPro.Composition.SetBodyPageUsage(Field("TEMPLATENAME"), true);

     

    Create a new template page with the Addressing information, and return it with a text rule

    return new FPRepeatableComponent('address');

     

    See attached modified PDF. If you wanted to keep down on your way you could just modify the "addressBlockAndIndicia" rule to your liking to return the template page you need.

    Postcard PreSort Mktg test.pdf.zip

  12. In JavaScript Globals add

     

    var gCount = 1;

     

    Change your rule to:

     

    var result = [];
    var r = CreateResource("test.pdf", "graphic");
    var count = StringToNumber((Field("Count")));
    var record = CurrentRecordNumber();
    
    for (var p = gCount; p < count + gCount; p++)
    {
       r.pagenumber = p;
       result.push(r.content);
    }
    
    
    return result.join("<br>\n");

     

    OnRecordEnd Rule

    gCount = gCount + StringToNumber(Field("Count"));

     

    If you need to start at a different page number in the source PDF than 1, just change the value in the javascript globals.

     

    Also, in the files you uploaded you'll need to assign the second page the type of "Overflow" in Page Usage.

  13. Those are missing glyph symbols. It's a result of the   character and whichever font you have assigned to the text not having a glyph specifically for it, I believe.

     

    if you change your return to something like this it should remove the boxes.

     

    return result.replace(" ","<f name=‘Helvetica’> </f>");

     

    Why does it preview and compose differently? I'm not sure. I always thought the preview was just a compose and convert to image happening in the background. But, I'm guessing there's a slightly different path happening which leads to the inconsistency.

  14. This will work i think:

     

    for (i=1; i<=4; i++){FusionPro.Composition.SetBodyPageUsage(i, false);}
    
    FusionPro.Composition.repeatRecordCount = Field("Output");
    
    var pageToCompose = FusionPro.Composition.repeatRecordNumber % 4;
    if (!pageToCompose){pageToCompose = 4;}
    
    FusionPro.Composition.SetBodyPageUsage(pageToCompose, true);
    
    FusionPro.Composition.AddVariable("iteration", Math.floor(((FusionPro.Composition.repeatRecordNumber - 1) / 4) + 1));

     

    This will also give you a variable you can insert for the iteration number.

×
×
  • Create New...