需要将内容与单元格右侧对齐。
如果单元格中存在空间需要用点填充
Hello Welcome to Stackoverflow
......Welcome to Stackoverflow
................ Stacloverflow
.................iiiiiiiiiiiii
.................WWWWWWWWWWWWW
注:
尝试了字符串的长度,但在实际值上,所有字符不占用相似的空间('W'与'i'相比占用双倍空间)
示例快照
预计
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xsl fo">
<xsl:variable name="thinBorder">1pt solid grey</xsl:variable>
<xsl:variable name="taskBorder">0.5pt dotted grey</xsl:variable>
<xsl:variable name="labelFontSize">7pt</xsl:variable>
<xsl:variable name="labelFontWeight">bold</xsl:variable>
<xsl:variable name="dataFontSize">8pt</xsl:variable>
<xsl:variable name="margin">2px</xsl:variable>
<xsl:variable name="taskMargin">10pt</xsl:variable>
<xsl:variable name="tableHeaderMarginTop">5px</xsl:variable>
<xsl:variable name="tableHeaderMarginBottom">1px</xsl:variable>
<!-- ================================================================== -->
<!-- Base template -->
<!-- ================================================================== -->
<xsl:template match="stxx/form">
<pageSize>
<page-width>21.59cm</page-width>
<page-height>28.30cm</page-height>
</pageSize>
<headerMargins>
<extent>1cm</extent>
</headerMargins>
<pageHeader>
<xsl:call-template name="report-header" />
</pageHeader>
<bodyMargins>
<marginTop>5.7cm</marginTop>
<marginBottom>3cm</marginBottom>
</bodyMargins>
<middle>
<fo-content>
</fo-content>
</middle>
<footerMargins>
<extent>2cm</extent>
</footerMargins>
<footer>
</footer>
</xsl:template>
<!-- ================================================================== -->
<!-- Template for Header -->
<!-- ================================================================== -->
<xsl:template name="report-header">
<fo:table font-size="{$dataFontSize}">
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="left" margin-left="45pt">
A/C <fo:inline font-weight="bold">7LP</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-weight="bold" text-align="right" margin-right="23pt">
Page
<fo:inline font-weight="bold"><fo:page-number/></fo:inline> of
<fo:inline font-weight="bold"><fo:page-number-citation ref-id="last-page"/></fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table border="solid 0.5mm black" text-align="left" table-layout="fixed" width="88.5%" font-size="{$dataFontSize}" margin-left="15.85mm">
<fo:table-body start-indent="0" end-indent="0">
<fo:table-row>
<fo:table-cell>
<fo:table margin-top="6px">
<fo:table-column column-width="10%"/>
<fo:table-column column-width="36%"/>
<fo:table-column column-width="5%"/>
<fo:table-column column-width="16%"/>
<fo:table-column column-width="30%"/>
<fo:table-column column-width="3%"/>
<fo:table-body start-indent="0" end-indent="0">
<fo:table-row margin-left="1px" height="30px">
<fo:table-cell>
<fo:block margin-left="{$margin}" margin-top="{$margin}" font-weight="{$labelFontWeight}" font-size="{$labelFontSize}">
Serial Number:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block-container overflow="hidden" height="20px">
<fo:block text-align="right">
<xsl:for-each select="1 to 10">...</xsl:for-each>73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-503573-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035 73-0500-8-5035
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block margin-left="{$margin}" margin-top="{$margin}" font-weight="{$labelFontWeight}" font-size="{$labelFontSize}">
Serial Number:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block-container overflow="hidden">
<fo:block text-align="right">
<xsl:for-each select="1 to 200">...</xsl:for-each>7302
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table>
<fo:table-column column-width="17%"/>
<fo:table-column column-width="80%"/>
<fo:table-column column-width="3%"/>
<fo:table-body start-indent="0" end-indent="0">
<fo:table-row margin-left="1px" height="30px">
<fo:table-cell>
<fo:block margin-left="{$margin}" margin-top="{$margin}" font-weight="{$labelFontWeight}" font-size="{$labelFontSize}">
Description:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block-container overflow="hidden">
<fo:block text-align="right">
<xsl:for-each select="1 to 40">...</xsl:for-each> CKC, ST25, 777-300, ST025 PKG
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table>
<fo:table-column column-width="6%"/>
<fo:table-column column-width="40%"/>
<fo:table-column column-width="5%"/>
<fo:table-column column-width="14%"/>
<fo:table-column column-width="32%"/>
<fo:table-column column-width="3%"/>
<fo:table-body start-indent="0" end-indent="0">
<fo:table-row margin-left="1px" height="30px">
<fo:table-cell>
<fo:block margin-left="{$margin}" margin-top="{$margin}" font-weight="{$labelFontWeight}" font-size="{$labelFontSize}">
Test:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block-container overflow="hidden">
<fo:block text-align="right">
<xsl:for-each select="1 to 100">...</xsl:for-each>X
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block margin-left="{$margin}" margin-top="{$margin}" font-weight="{$labelFontWeight}" font-size="{$labelFontSize}">
Test Description:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block-container overflow="hidden">
<fo:block text-align="right">
<xsl:for-each select="1 to 20">...</xsl:for-each>N/A
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
使用
fo:leader
,可以制作一系列点来填充当前行上的可用空间。 (参见https://www.w3.org/TR/xsl11/#fo_leader)
来自https://stackoverflow.com/a/78673746/4092205:
有关如何使用
fo:leader
的讨论,请参阅 https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#axf.leader-expansion 和 fo:leader
中的示例
来自 XSL-FO 示例集合的示例,网址为 https://www.antennahouse.com/xsl-fo-samples。特别请参阅 https://www.antennahouse.com/xsl-fo-samples#axf-last-right-justify-1,PDF 位于 https://www.antennahouse.com/hubfs/xsl-fo-样本/行/axf-last-right-justify-1.pdf?hsLang=en。其中的 fo:block-container
样本是:
<fo:block-container text-align="justify" text-align-last="right">
<fo:block>Lorem ipsum dolor sit amet, consectetur adipiscing cons equat elit...
<fo:leader />
<fo:leader leader-length.optimum="100%" />
<fo:inline keep-together.within-line="always">Antenna House</fo:inline>
</fo:block>
</fo:block-container>