[xep-support] Re: Centering a block of text

From: Cooper, Craig (LNG-PEO) <craig.cooper@lexisnexis.com>
Date: Tue Dec 27 2011 - 09:33:34 PST

Sorry for not providing more detail on this specific application. The text that needs to be centered is a name/address style block where lines will vary significantly in length but cannot wrap however the client wants the block to appear centered on the page. Because of this I cannot set a static size for the column it appears in.

Ken Holman's technique of using a 3 column table with the first and last columns having proportional widths was a great starting point but I found that with really narrow content in the center cell the column width stayed larger than the content. After further experimentation I found that instead of...

<fo:table-column column-width="proportional-column-width(1)" />
<fo:table-column />
<fo:table-column column-width="proportional-column-width(1)" />

I could use...
<fo:table-column column-width="proportional-column-width(100)" />
<fo:table-column />
<fo:table-column column-width="proportional-column-width(100)" />

And this appears to force the first and last columns to be as large as possible while allowing the center column to expand or contract exactly with the content no matter how wide or narrow it wound up being. The number 100 was chosen somewhat arbitrarily after finding that a value of 2 drove the formatting closer to what I wanted. I can't honestly say I have a firm grasp on why this works but suffice it to say that it does.

Example...

<fo:table width="100%">
        <fo:table-column column-width="proportional-column-width(100)" />
        <fo:table-column />
        <fo:table-column column-width="proportional-column-width(100)" />
        <fo:table-body>
                <fo:table-cell />
                <fo:table-cell>
                        <fo:table-cell text-align="left" display-align="before">
                                <fo:block text-align="left" margin-left="2pt" padding-left="2px" padding-right="2px" padding-top="2px" padding-bottom="2px">
                                        <fo:block>
                                                <fo:inline keep-together.within-line="always">Johnathan M. Murphy Agent</fo:inline>
                                        </fo:block>
                                        <fo:block>
                                                <fo:inline keep-together.within-line="always">AAMS<fo:leader leader-length="2pt" />, CFA<fo:leader leader-length="2pt" />, CRCP</fo:inline>
                                        </fo:block>
                                        <fo:block>
                                                <fo:inline keep-together.within-line="always">Exclusive Agent</fo:inline>
                                        </fo:block>
                                </fo:block>
                        </fo:table-cell>
                </fo:table-cell>
                <fo:table-cell />
        </fo:table-body>
</fo:table>

Craig Cooper
Consulting Software Engineer
Insurance Marketing Solutions
LexisNexis   |   Risk Solutions
309.689.6416  Direct
309.231.1598  Cell
craig.cooper@lexisnexis.com

-----Original Message-----
From: xep-support-bounces@renderx.com [mailto:xep-support-bounces@renderx.com] On Behalf Of Kevin Brown
Sent: Friday, December 23, 2011 2:58 PM
To: 'RenderX Community Support List'
Subject: [xep-support] Re: Centering a block of text

I with Ken on this one, not sure what "dynamic change" you are looking for.

For instance, if you wish the centered block to be 2in wide, then this is
perfect:

                        <fo:table width="100%">
                                <fo:table-column
column-width="proportional-column-width(1)"/>
                                <fo:table-column column-width="2in"/>
                                <fo:table-column
column-width="proportional-column-width(1)"/>
                                <fo:table-body>
                                        <fo:table-row>
        
<fo:table-cell><fo:block><fo:leader/></fo:block></fo:table-cell>
                                                <fo:table-cell>
                                                        <fo:block>I am a
happy little line of left-aligned text within a 2in centered table
column.</fo:block>
                                                </fo:table-cell>
        
<fo:table-cell><fo:block><fo:leader/></fo:block></fo:table-cell>
                                        </fo:table-row>
                                        
                                </fo:table-body>
                        </fo:table>

Kevin Brown
RenderX

-----Original Message-----
From: xep-support-bounces@renderx.com
[mailto:xep-support-bounces@renderx.com] On Behalf Of G. Ken Holman
Sent: Friday, December 23, 2011 12:33 PM
To: RenderX Community Support List; RenderX Community Support List
Subject: [xep-support] Re: Centering a block of text

At 2011-12-23 14:55 -0500, Cooper, Craig (LNG-PEO) wrote:
>I'm trying to find a way to horizontally center a block of text on a
>page but within the block have text be left justified. I've tried
>some 3 column table techniques with no success because I need the
>block of text to dynamically change with but still have the entire
>block be centered.

What kind of "dynamic changes" do you need to support that cannot be
accommodated with a table cell?

 . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/f/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal
_______________________________________________
(*) To unsubscribe, please visit
http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service
http://w
ww.renderx.com/terms-of-service.html
_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html
-----------------------------------------
The information contained in this e-mail message is intended only
for the personal and confidential use of the recipient(s) named
above. This message may be an attorney-client communication and/or
work product and as such is privileged and confidential. If the
reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are
hereby notified that you have received this document in error and
that any review, dissemination, distribution, or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by e-mail, and
delete the original message.
!DSPAM:87,4efa01b363739824620443!
_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html
Received on Tue Dec 27 09:35:08 2011

This archive was generated by hypermail 2.1.8 : Tue Dec 27 2011 - 09:35:13 PST