XSL-FO - 中心文字不起作用

时间:2014-04-01 16:33:23

标签: alignment center xsl-fo text-alignment

在我的XSL-FO中,我遇到了文本居中的问题,因为它将脚注行2分成2个句子,而不是走到页面的整个长度,然后一旦它用完房间就打破了句子。见下图。

我有这段代码:

    <fo:block font-size="9pt" text-align="center">
        <xsl:value-of select="footnote-line1"/>
    </fo:block>
    <fo:block font-size="9pt" text-align="center">
        <xsl:value-of select="footnote-line2"/>
    </fo:block>  

这是我的XML:

    <footnote-line1>This verification of XXXXXX is self-generated and is produced by John Smith from our secure website.</footnote-line1>
    <footnote-line2>If there are any questions regarding the information contained in this letter, you may contact the Joe Blow at his office at the contact information noted above.</footnote-line2>

生成此输出:enter image description here

不幸的是,上面的图片并不是我想要的,因为在#34;你&#34;。

之后它正在进行段落休息。

以下2张图片是我希望获得的输出。我实现的第一个图像是将字体缩小到6pt,但我不想缩小字体。

选项1)替代解决方案,但不要缩小字体大小

enter image description here

选项2)不缩小字体的最佳解决方案

enter image description here

我如何实现选项#2?

使用彩色背景更新,两者的长度与第一个和第二个脚注的长度相同: enter image description here

以下是完整的XSL-FO文档:

<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8"/>
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <fo:root font-family="Times Roman" font-size="9pt">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="main-voe"
                    margin-top="15mm" margin-bottom="15mm" margin-left="25mm" margin-right="25mm" page-width="215mm" page-height="279mm">
                    <fo:region-body margin-top="1.0in" margin-bottom="1.0in"/>
                    <fo:region-before extent="1.0in" margin-top="1.0in"/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="main-voe" initial-page-number="1">
                <fo:static-content flow-name="xsl-region-before" font-size="9pt">
                    <fo:block>
                        <xsl:apply-templates select="enrolment/address-dept-info"/>
                    </fo:block>
                </fo:static-content>
                <fo:flow flow-name="xsl-region-body" font-size="9pt">
                    <fo:block font-weight="bold" linefeed-treatment="preserve" space-after="9pt">
                        <xsl:apply-templates select="enrolment/letter"/>
                    </fo:block>
                    <fo:block linefeed-treatment="preserve" font-weight="bold" space-after="9pt">
                        Notes:      
                    </fo:block>
                     <xsl:apply-templates select="enrolment/student-info/student-notes/student-notes-details"/>
                    <xsl:apply-templates select="enrolment/signature"/>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
        <!-- This sections builds the header information at the top of the page  -->
    <xsl:template match="address-dept-info">
        <fo:table table-layout="fixed" width="100%">
            <fo:table-column column-width="25mm" padding="0"/>
            <fo:table-column column-width="100mm"/>
            <fo:table-column column-width="85mm"/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block>
                            Logo info
                        </fo:block>                        
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block linefeed-treatment='preserve'
                            white-space-collapse='false'><xsl:value-of select="address1"/></fo:block>
                        <fo:block linefeed-treatment='preserve'
                            white-space-collapse='false'><xsl:value-of select="address2"/></fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block linefeed-treatment='preserve'
                            white-space-collapse='false'>
                            <xsl:value-of select="dept/dept-name"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>       
    </xsl:template>
    <xsl:template match="student-info">
        <fo:block linefeed-treatment="preserve" space-after="9pt">
            <fo:table table-layout="fixed" width="100%">
                <fo:table-column column-width="5mm"/>
                <fo:table-column column-width="80mm"/>
                <fo:table-column column-width="100mm"/> 
                <fo:table-body>
                    <xsl:apply-templates select="//student-info/student-program/student-program-details"/>
                </fo:table-body>    
            </fo:table>
        </fo:block>
    </xsl:template>
    <xsl:template match="student-notes/student-notes-details">
        <xsl:value-of select="description"/>
    </xsl:template>    
    <xsl:template match="signature">
        <fo:block linefeed-treatment='preserve' space-after="9pt">
            Sincerely,
        </fo:block> 
        <fo:block linefeed-treatment='preserve' space-after="12pt">
            <xsl:value-of select="first-name"/><xsl:text> </xsl:text> <xsl:value-of select="last-name"/><xsl:text>&#10;</xsl:text>
            <xsl:value-of select="position"/><xsl:text>&#10;</xsl:text>
        </fo:block>
        <fo:block font-size="9pt" text-align="center" background-color="grey">
            <xsl:value-of select="//letter/footnote-line1"/>
        </fo:block>
        <fo:block font-size="9pt" text-align="center" background-color="yellow">
                <xsl:value-of select="//letter/footnote-line2"/>
        </fo:block>
    </xsl:template> 
    <xsl:template match="letter">
        <fo:block linefeed-treatment='preserve' text-align="center">
            <xsl:value-of select="title"/>
        </fo:block>
    </xsl:template> 
</xsl:stylesheet>

由于 干杯

1 个答案:

答案 0 :(得分:0)

我用FOP测试了这个,你就得到了答案。抱歉。这是FOP。您可以将其报告为错误。

使用RenderX XEP可以得到您想要的答案,并且应该正确期待。

enter image description here