Melaperu Posted April 1, 2014 Share Posted April 1, 2014 Please see my code below, I am trying to make office, fax, mobile tags smaller, but am unsure of where or what code to add to the tags. Gotham is the font family that needs to be 4pt. Thank you so much for your help!!!! Melanie var greenPMS = "PANTONE 361 C"; // The name of the green color in your template (phone labels) var grayPMS = "PANTONE 425 C"; // The name of the gray color in your template (numbers) var phone1 = Field("office"); // Replace with your field name var phone2 = Field("fax"); // Replace with your field name var phone3 = Field("mobile"); // Replace with your field name var label1 = " OFFICE"; var label2 = "FAX"; var label3 = "MOBILE"; // Array of numbers and labels var numbers = [[phone1,label1],[phone2,label2],[phone3,label3]]; // Remove elements that don't have a phone number from the array numbers = numbers.filter(function(s){return s[0];}); // Add color tags, format numbers, & add a pipe ( | ) between labels/numbers for (var i=0; i<numbers.length; i++){ numbers[i][0] = '<color name="'+ grayPMS +'">' + numbers[i][0] + '</color>'; numbers[i][1] = '<f name="Gotham Bold">' + '<color name="'+ greenPMS +'">' + formatPhone(numbers[i][1]) + '</color>' + '</f>'; numbers[i] = numbers[i].join('<color name="'+ grayPMS +'"> </color>'); } // Join with a line break return numbers.join('<color name="'+ greenPMS +'"> I </color>') //=============================================================== // // DON'T EDIT BELOW THIS LINE // //=============================================================== function formatPhone(num){ var Var1 = num; var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "$1.$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 $2.$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "$1.$2.$3 x$4"; //10 digit phone with extension var formatStyle05 = "+$1 $2.$3.$4 x$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 x$3"; //7 digit phone with extension var thisNumber = Var1; return formatNumber(Trim(thisNumber)); function formatNumber(number01){ var pattern01 = /^(\d{3})[^\d]*(\d{4})$/; var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var patternEndExt = /(.)[x#n](.)/; var patternStart1 = /^[\D]*[1]/; if(number01.match(pattern01)){ number01 = number01.replace(pattern01, formatStyle01); return number01; } else if(number01.match(pattern02)){ number01 = number01.replace(pattern02, formatStyle02); return number01; } else if(number01.match(pattern03)){ if (number01.match(patternStart1)){ number01 = number01.replace(pattern03, formatStyle03); return number01; } else { return number01; } } else if(number01.match(pattern04)){ number01 = number01.replace(pattern04, formatStyle04); return number01; } else if(number01.match(pattern05)){ number01 = number01.replace(pattern05, formatStyle05); return number01; } else if(number01.match(pattern06)){ number01 = number01.replace(pattern06, formatStyle06); return number01; } else { return number01; } } } Quote Link to comment Share on other sites More sharing options...
David Miller Posted April 1, 2014 Share Posted April 1, 2014 (edited) You can try this. Updates to your code are in red. var greenPMS = "PANTONE 361 C"; // The name of the green color in your template (phone labels) var grayPMS = "PANTONE 425 C"; // The name of the gray color in your template (numbers) var phone1 = Field("office"); // Replace with your field name var phone2 = Field("fax"); // Replace with your field name var phone3 = Field("mobile"); // Replace with your field name var label1 = "OFFICE"; var label2 = "FAX"; var label3 = "MOBILE"; [color="Red"]var sizeLabel = "4"; // The point size of your phone labels var sizePhone = "8"; // The point size of your phone numbers var sizeSeparator = "10" // The point size of your separator[/color] // Array of numbers and labels var numbers = [[phone1,label1],[phone2,label2],[phone3,label3]]; // Remove elements that don't have a phone number from the array numbers = numbers.filter(function(s){return s[0];}); // Add color tags, format numbers, & add a pipe ( | ) between labels/numbers for (var i=0; i<numbers.length; i++){ numbers[i][0] = [color="red"]'<z newsize="'+ sizePhone+'">' + [/color]'<color name="'+ grayPMS +'">' + numbers[i][0] + '</color>'; numbers[i][1] = '<f name="Gotham Bold">' + [color="red"]'<z newsize="'+ sizeLabel+'">' + [/color]'<color name="'+ greenPMS +'">' + formatPhone(numbers[i][1]) + '</color>' + '</f>'; numbers[i] = numbers[i].join('<color name="'+ grayPMS +'"> </color>'); } // Join with a line break return numbers.join([color="red"]'<z newsize="'+ sizeSeparator+'">' + [/color]'<color name="'+ greenPMS +'"> [color="Magenta"]I[/color] </color>')[color="red"];[/color] //=============================================================== // // DON'T EDIT BELOW THIS LINE // //=============================================================== function formatPhone(num){ var Var1 = num; var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "$1.$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 $2.$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "$1.$2.$3 x$4"; //10 digit phone with extension var formatStyle05 = "+$1 $2.$3.$4 x$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 x$3"; //7 digit phone with extension var thisNumber = Var1; return formatNumber(Trim(thisNumber)); function formatNumber(number01){ var pattern01 = /^(\d{3})[^\d]*(\d{4})$/; var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; var patternEndExt = /(.)[x#n](.)/; var patternStart1 = /^[\D]*[1]/; if(number01.match(pattern01)){ number01 = number01.replace(pattern01, formatStyle01); return number01; } else if(number01.match(pattern02)){ number01 = number01.replace(pattern02, formatStyle02); return number01; } else if(number01.match(pattern03)){ if (number01.match(patternStart1)){ number01 = number01.replace(pattern03, formatStyle03); return number01; } else { return number01; } } else if(number01.match(pattern04)){ number01 = number01.replace(pattern04, formatStyle04); return number01; } else if(number01.match(pattern05)){ number01 = number01.replace(pattern05, formatStyle05); return number01; } else if(number01.match(pattern06)){ number01 = number01.replace(pattern06, formatStyle06); return number01; } else { return number01; } } } You will need to set the point size of the label, phone and separator. See comments above. More information can be found in the FusionPro VDP Creator Tags Reference Guide. BTW: The separator in your code is actually the uppercase letter "I". Not the pipe (|) character. Colored pink in your code. Edited April 1, 2014 by David Miller Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.