#1
|
|||
|
|||
![]()
I am trying to adjust where the address is centered under a logo.
The problem is that if either line of text is wider than the logo then I'd like to have the widest line start at the same x coordinate as the logo (left justified under logo). Then the shortest line would be centered under the widest line. I've attached a pdf of 3 examples. The top example shows what address block looks like centered under logo-all the text is narrower than logo. Middle example shows what I'd like to happen if the street address line is the longest. Bottom example shows what I'd like to happen if the city, state zip line is the longest. Is the best route to adjust this add a center tab and then adjust tab position based on text line width? Or, can I adjust the width of the text frame based on longest line of text? Thanks, Jeremy
__________________
Jeremy Acrobat Pro DC 2017 FusionPro VDP Creator 10.0.16 Mac OS X 10.11.6 |
#2
|
||||
|
||||
![]()
If you're composing this job using FPServer, you can adjust the text frame width based on the largest line. However, you'd be able to mimic that functionality by using a 1 column, 2 row table. In the example below, you set the 'width' variable to the width of your logo. If neither line exceeds that width then the table will be the same width as the logo and the text will be centered inside it. If either line is longer, the table's width will be set to match that of the longest line and the text will be centered inside. Since the table itself is left aligned, a line of text that is centered within a table of the same width will also appear to be left-aligned while the shorter lines appear centered.
Code:
var address = '223 Blue Green Yellow Red Pkwy'; var csz = 'Anytown, USA 12345'; var width = 7200; // Width of logo. 7200 = 1" function getTextWidth(input){ var tm = new FusionProTextMeasure; tm.font = 'Helvetica'; // Your font tm.pointSize = '12 pt'; // Your font size tm.CalculateTextExtent(input); return tm.textWidth; } address = [address, csz]; for (var i in address) if ((w = getTextWidth(address[i])) > width) width = w; var table = new FPTable(); table.AddColumn(width*1.001); for (var i in address) { var row = table.AddRow(); var cell = row.Cells[0]; cell.Margins = {Top:10, Bottom:10, Right:0, Left:0}; cell.HAlign = 'Center'; row.SetContents(address[i]); } return table.MakeTags();
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#3
|
|||
|
|||
![]()
Step,
Thanks again for your help. I used the code you suggested and all works as needed on the Mac. I switch to a Windows 8 machine to compose so that the Helvetica font will embed. When I switch to Windows 8, I am having problems with Myriad Pro Italic font. I enter "MyriadPro-It" instead of "Helvetica" in the font measure function. It's not working correctly-column width is wider than longest line of text. In my very brief experience with measuring text width that means that I don't have the correct name in the code. I copied the font name from fonts.ini but that doesn't help either. How do I find the correct name for Myriad Pro Italic so that it composes correctly? Thanks, Jeremy Thanks, Jeremy
__________________
Jeremy Acrobat Pro DC 2017 FusionPro VDP Creator 10.0.16 Mac OS X 10.11.6 |
#4
|
||||
|
||||
![]() Quote:
Quote:
Usually, the font name for the <f name="***"> tag is the same font name displayed in the fonts drop-down list in the Text Editor. But remember that fonts work a bit differently on Windows and Mac. On Windows, the names in that font drop-down are really font family names, and the way to get different styles (faces) of a font family is to use the B and I buttons in the Text Editor (or <b> and <i> markup tags) for bold and italic. The FusionProTextMeasure object also has bold and italic properties to specify the styles of the specified font family. So, on Windows, you probably need to specify "Myriad Pro" as the font family name, and then set the italic property to true, like so: Code:
tm.font = 'Myriad Pro'; // Your font FAMILY tm.italic = true; // Italic style/face
__________________
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)}); ![]() Last edited by Dan Korn; December 23rd, 2015 at 11:18 AM.. |
#5
|
|||
|
|||
![]()
Myriad Pro-It
Quote:
Thanks!
__________________
Jeremy Acrobat Pro DC 2017 FusionPro VDP Creator 10.0.16 Mac OS X 10.11.6 |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|