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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 13th, 2014, 11:52 AM
EvanF EvanF is offline
Forum n00b
 
Join Date: Dec 2013
Posts: 7
Default Right Justified text, and left line alignment

I have a right justified Email, and I need to align the Cellphone line to the left most extents of the Email line.

I have a formatting issue I've been trying to tackle, however the FusionProTextMeasure seems to be limited by a defined point size, so when copyfit takes over the measurement is no longer accurate. I'm not sure if this is even the best way to approach this as I'm quite new to FusionPro.

This approach calculates the size of both lines, subtracts them to get the difference and tosses that into a rindent tag format for the cellphone line.

Code:
var rightIndentSize = function () {
    // Default Pt Size
    var ptSize = "6 pt";

    // Email Size
    var emailString = "email: " + Rule("Email_Format");
    var emailTM = new FusionProTextMeasure;
    emailTM.pointSize = ptSize;
    emailTM.font = "Helvetica";
    emailTM.useTags = false;
    emailTM.CalculateTextExtent(emailString);

    // Cellphone Size
    var cellString = "cell: " + Rule("Cellphone_Format");
    var cellTM = new FusionProTextMeasure;
    cellTM.pointSize = ptSize;
    cellTM.font = "Helvetica";
    cellTM.useTags = false;
    cellTM.CalculateTextExtent(cellString);

    // Calculate difference in size
    var tmWidth = (emailTM.textWidth - cellTM.textWidth);
    return tmWidth;
}

return "<p rindent=" + rightIndentSize() + ">" + "cell: " + Rule("Cellphone_Format") + "</p>";
I'd like to have this work with copyfit as some of the emails are bound to get quite long. Also it would be nice if the rules weren't hard coded for font sizes, might make the rules a little more versatile.

Any help is much appreciated.

Thanks,
Evan
Attached Files
File Type: zip Archive.zip (6.5 KB, 7 views)
Reply With Quote
  #2  
Old March 13th, 2014, 12:31 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Right Justified text, and left line alignment

I think it has to do with using the right indent. If you left justify your text box, remove the email rule from it, you can simplify things a bit by modifying your "Test_testbox" rule to look like this:
Code:
var frameWidth = 1.89 * 7200; // 1.89 inches


var email = "email: " + ToLower(Field("Email"));
var cell = "cell: " + Rule("Cellphone_Format");

// Email Size
    var emailTM = new FusionProTextMeasure;
    emailTM.pointSize = "6 pt";
    emailTM.font = "Helvetica";
    emailTM.useTags = false;
    emailTM.italic = true;
    emailTM.CalculateTextExtent(email);
    var indent = frameWidth-emailTM.textWidth;

return "<p findent=" + indent + ">" + cell + "</p><br><p findent=" + indent + ">" + email + "</p>";
It's essentially indenting the email address to be right aligned and indents the cellphone number the same amount (from the left). Copyfit works with those modifications.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old March 13th, 2014, 01:01 PM
EvanF EvanF is offline
Forum n00b
 
Join Date: Dec 2013
Posts: 7
Default Re: Right Justified text, and left line alignment

Thank you! Appreciate the quick reply.
Reply With Quote
  #4  
Old March 13th, 2014, 02:05 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,381
Default Re: Right Justified text, and left line alignment

You can do this without writing a rule at all. One way is to just type whatever you need into the Text Editor, and put a tab in between the two parts. Then click the Tabs button, and in the Edit Tab Stops dialog, add a right-aligned tab stop, with the position just a bit less than the width of the frame.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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)});

Last edited by Dan Korn; March 13th, 2014 at 02:06 PM.. Reason: typo
Reply With Quote
  #5  
Old March 20th, 2014, 11:02 AM
EvanF EvanF is offline
Forum n00b
 
Join Date: Dec 2013
Posts: 7
Default Re: Right Justified text, and left line alignment

Quote:
Originally Posted by Dan Korn View Post
You can do this without writing a rule at all. One way is to just type whatever you need into the Text Editor, and put a tab in between the two parts. Then click the Tabs button, and in the Edit Tab Stops dialog, add a right-aligned tab stop, with the position just a bit less than the width of the frame.
Can you provide a sample of this as it doesn't seem to work as you describe. As the solution Step provided isn't quite working as intended.
Reply With Quote
  #6  
Old March 20th, 2014, 05:10 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,381
Default Re: Right Justified text, and left line alignment

Quote:
Originally Posted by EvanF View Post
Can you provide a sample of this as it doesn't seem to work as you describe. As the solution Step provided isn't quite working as intended.
Okay, here you go.
Attached Files
File Type: pdf FusionProTabExample.pdf (6.1 KB, 53 views)
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
  #7  
Old March 12th, 2015, 07:53 PM
PabloTI PabloTI is offline
Forum n00b
 
Join Date: Sep 2014
Posts: 1
Default Re: Right Justified text, and left line alignment

Thanks for giving the example using tabs and right align.
Solved a problem I was having with a variable menu board. When ever a price was over 9.99 it was pushing the numbers out of alignment. Using tab and right align made it all line up nicely.
Reply With Quote
  #8  
Old March 13th, 2014, 02:10 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,381
Default Re: Right Justified text, and left line alignment

Also, just a comment on this:
Quote:
Originally Posted by EvanF View Post
however the FusionProTextMeasure seems to be limited by a defined point size
That's true only if you have the useTags property of the FusionProTextMeasure object set to false. If you set it to true, then you can use multiple <z newsize=***> and other formatting tags in the text, which can have as many "runs" of text with different point sizes and other attributes as you want, and it will measure the entire thing.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
Reply

Tags
copyfit, textmeasure

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 10:17 PM.


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