【发布时间】:2014-05-12 13:41:59
【问题描述】:
在我的 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>
生成此输出::
不幸的是,上面的图片不是我想要的,因为它在“你”这个词之后做了一个分段。
下面这两张图片是我希望得到的输出。我实现的第一张图片是将字体缩小到 6pt,但我不想缩小字体。
选项1)替代解决方案,但宁愿不缩小字体大小
选项2)不缩小字体的最佳解决方案
我将如何实现选项 #2?
更新了彩色背景,第一个和第二个脚注的长度相同:
这是完整的 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> </xsl:text>
<xsl:value-of select="position"/><xsl:text> </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>
谢谢 干杯
【问题讨论】:
-
您使用什么来输出您的 XSL-FO(FOP、Antenna House、RenderX 等)?实际上,我更经常发现相反的问题。我希望文本平衡,但它不会。但我不确定我是否看到过居中文本,特别是。
-
@Christina 我正在使用 Apache FOP
-
看起来区域显示区域对于这个脚注行元素是有限的。请检查其父元素是否设置了左右空格或缩进等。使用背景颜色来注意显示这些内容的实际区域。
-
@NavinRawat 我用不同的颜色更新了背景,第一行和第二行的宽度相同。见上图
-
@MoxieC:您能否向我们展示一份完整的 FO 文档来展示该问题?尝试使其尽可能小。这样会更容易提供帮助。
标签: alignment center xsl-fo text-alignment