Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text


Thread Tools Search this Thread Display Modes
Old May 23rd, 2013, 06:22 AM
EricC EricC is offline
Regular Contributor
Join Date: Nov 2008
Posts: 87
Arrow Horizontally Scale only part of returned text

I am using the Telephone Format Rule to return the word "Tel:" plus the phone number.

I only want the tag line "Tel:" to have a horizontal scale of 80%.
The actual phone number should not have any scaling applied (100%).

When I use the rule below and preview in FusionPro, the entire line is scaled 80% - the word "Tel:" AS WELL AS the phone number.

Can't figure out what I am doing wrong. Is this a bug?
Using FusionPro 9.0.3, Acrobat X Pro 10.1.7 and Windows 8 Pro.

// Rule-Tel1
// Formats Phone Number

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 ext.$4";    //10 digit phone with extension
var formatStyle05 = "$1.$2.$3.$4 ext.$5"; //10 digit phone starts with 1 with extension
var formatStyle06 = "$1.$2 ext.$3";       //7 digit phone with extension
var thisNumber = Field("Tel1");

if (thisNumber == "")
    return "";
    return '<magnify type=setwidth factor=80>Tel:</magnify><t>' + formatNumber(Trim(thisNumber));

// DO NOT EDIT BELOW THIS LINE ///////////////////////////////////////////////////////////////////////

function formatNumber(number01)
    var pattern01 = /^(\d{3})[^\d]*(\d{4})$/;                                                     // 2201727 or 220-1727 or 220- 1727
    var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/;                                     // 8002201727 or 800-220-1727 or (800)220-1727 or (800) 220-1727
    var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/;                           // 18002201727 or 1-800-220-1727 or +1 (800) 220-1727
    var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[Xx\.\-\+\*#Nn]\D*(\d+)$/;           // 800-220-1727 ext 12345 or (800) 220-1727 ext 12345
    var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[Xx\.\-\+\*#Nn]\D*(\d+)$/; // 1-800-220-1727 ext 12345 or +1 (800) 220-1727 ext 12345
    var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[Xx\.\-\+\*#Nn]\D*(\d+)$/;                            // 2201727 ext 1234 or 220-1727 ext 1234 or 220- 1727 ext 1234
    var patternEndExt = /(.)[Xx\.\-\+\*#Nn](.)/;
    var patternStart1 = /^[\D]*[1]/;

        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 "no match any pattern";
        return number01;
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
Old May 23rd, 2013, 10:16 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Horizontally Scale only part of returned text

I've never used the magnify tag before, but in the guide it mentions this tag is used "to perform copy-fitting on text that is already formatted with tagged-markup that changes character appearances". Not sure if that is part of your problem, but perhaps you could use the setwidth tag instead? Keep in mind that it has no closing tag so you would need to add a second tag to "reset" the width for the number.
Eric Smith
Content Developer
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
Old May 24th, 2013, 08:24 AM
EricC EricC is offline
Regular Contributor
Join Date: Nov 2008
Posts: 87
Default Re: Horizontally Scale only part of returned text

Hi Eric,
I tried setwidth and got the same exact result.

And even though (as you mentioned) it's not needed, I wrapped the actual phone number around a SECOND <magnify> tag, setting it back to 100%. But that didn't work.

I'll try to play around with it some more but I keep looking at my code and it looks correct.
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
Old June 6th, 2013, 01:54 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,467
Default Re: Horizontally Scale only part of returned text

This isn't completely clear in the Tags Reference Guide, but the ending </magnify> tag does not revert the magnification settings until the start of the next paragraph. The behavior could be changed, but that's how it's always worked.

If you want to temporarily change an attribute of the text, and be able to change it back again before the end of the paragraph, you can use a <span> tag and then an ending </span> tag.

Unfortunately, the <span> tag does not give you the ability to modify the setwidth of the text directly like the <magnify> tag does.

However, the </span> tag will restore all the attributes of the text back to what was in effect when the initial <span> tag was issued. So, you can use the <magnify> and <span> tags together to achieve the effect you want, like so:
return '<span><magnify type=setwidth factor=80>Tel:</magnify></span><t>' + formatNumber(Trim(thisNumber));
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote

horizontal scale, magnify, phone

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 05:30 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.