有条件的页面 - 进入 fo:table
Conditional page - breaking in fo:table
我尝试在 fo:table 中插入条件分页符 - 但没有成功!
这是我的 XSL:FO 模板的一部分:
<xsl:template match="Lignes">
<fo:block-container width="100%" top="11cm"
position="absolute">
<fo:block color="black" font-family="Tahoma" font-size="12px"
font-weight="normal">
my title
</fo:block>
<fo:block white-space-collapse="false"
white-space-treatment="preserve" font-size="0pt" line-height="10px">.
</fo:block>
<fo:block color="black" font-family="Tahoma" font-size="10px"
font-weight="normal">
<fo:table table-layout="fixed" border-spacing="3px 3px">
<fo:table-column column-width="20%" />
<fo:table-column column-width="30%" />
<fo:table-column column-width="8%" />
<fo:table-column column-width="15%" />
<fo:table-column column-width="12%" />
<fo:table-column column-width="15%" />
<fo:table-header background-color="#EFEFEF"
border-width="1px" border-style="solid">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 1
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 2
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 3
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 4
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 5
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 6
</fo:block>
</fo:table-cell>
</fo:table-header>
<fo:table-footer>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
Total H.T
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of
select="format-number(/Devis/Corps/Footer/mt_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="/Devis/Corps/Footer/TVA/Ligne_TVA">
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
<xsl:text>TVA (</xsl:text>
<xsl:value-of select="taux" />
<xsl:text> %)</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of select="format-number(mt_tva, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
Total T.T.C
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of
select="format-number(/Devis/Corps/Footer/mt_ttc, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body background-color="white" border-color="black"
border-width="1px" border-style="solid">
<xsl:for-each select="Ligne">
<!-- page break -->
<xsl:if test="position() mod 3 = 0">
<fo:table-row break-before="page">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="ref" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="designation" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="qte" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:value-of select="format-number(pu_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:if test="remise > 0">
<xsl:value-of select="format-number(remise, '### ###.00')" />
</xsl:if>
<xsl:if test="contains(remise, '%')">
<xsl:value-of select="remise" />
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:value-of select="format-number(total_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:block-container>
</xsl:template>
这是我的 XML 文件的一部分:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Devis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="_dt.xsd">
<Corps>
<Lignes>
<Ligne>
<ref>ASUS97_105</ref>
<designation>produit 1</designation>
<qte>1</qte>
<pu_ht>160</pu_ht>
<remise>34.55</remise>
<total_ht>125.45</total_ht>
</Ligne>
<Ligne>
<ref>FORT1</ref>
<designation>produit 2</designation>
<qte>1</qte>
<pu_ht>60</pu_ht>
<remise>15%</remise>
<total_ht>51</total_ht>
</Ligne>
<Ligne>
<ref>FORT2</ref>
<designation>produit 3</designation>
<qte>1</qte>
<pu_ht>70</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT3</ref>
<designation>produit 4</designation>
<qte>1</qte>
<pu_ht>80</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT4</ref>
<designation>produit 5</designation>
<qte>1</qte>
<pu_ht>70</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT5</ref>
<designation>produit 6</designation>
<qte>1</qte>
<pu_ht>80</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
</Lignes>
<Footer>
<mt_ht>185.45</mt_ht>
<TVA>
<Ligne_TVA>
<mt_tva>37.09</mt_tva>
<taux>20</taux>
</Ligne_TVA>
</TVA>
<mt_ttc>222.54</mt_ttc>
<duree>60</duree>
<Check>
<path>checkbox.png</path>
<path_pdf>file:/D:/checkbox.png</path_pdf>
</Check>
<Commentaire_refus_devis>
<Ligne_commentaire>
<commentaire>commentaire 1
</commentaire>
</Ligne_commentaire>
<Ligne_commentaire>
<commentaire>commentaire 2
</commentaire>
</Ligne_commentaire>
<Ligne_commentaire>
<commentaire>commentaire 3
</commentaire>
</Ligne_commentaire>
</Commentaire_refus_devis>
</Footer>
</Corps>
</Devis>
我的 PDF 文件中没有分页符!
有什么想法吗?
提前致谢
调频
您的 fo:table
在绝对定位的 fo:block-container
中。
Only objects with absolute-position="auto" may have page/column
breaks.
For other values any keep and break properties are ignored.
因此,您的分页符被正确地忽略了。
提议的更改:
- 删除
fo:block-container
- 而不是
fo:block-container
上的 top="11cm"
,您可以在 fo:region-body
上使用 margin-top="11cm"
(或在其当前值上增加 11cm)
我尝试在 fo:table 中插入条件分页符 - 但没有成功!
这是我的 XSL:FO 模板的一部分:
<xsl:template match="Lignes">
<fo:block-container width="100%" top="11cm"
position="absolute">
<fo:block color="black" font-family="Tahoma" font-size="12px"
font-weight="normal">
my title
</fo:block>
<fo:block white-space-collapse="false"
white-space-treatment="preserve" font-size="0pt" line-height="10px">.
</fo:block>
<fo:block color="black" font-family="Tahoma" font-size="10px"
font-weight="normal">
<fo:table table-layout="fixed" border-spacing="3px 3px">
<fo:table-column column-width="20%" />
<fo:table-column column-width="30%" />
<fo:table-column column-width="8%" />
<fo:table-column column-width="15%" />
<fo:table-column column-width="12%" />
<fo:table-column column-width="15%" />
<fo:table-header background-color="#EFEFEF"
border-width="1px" border-style="solid">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 1
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 2
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">Column 3
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 4
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 5
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">Column 6
</fo:block>
</fo:table-cell>
</fo:table-header>
<fo:table-footer>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
Total H.T
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of
select="format-number(/Devis/Corps/Footer/mt_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="/Devis/Corps/Footer/TVA/Ligne_TVA">
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
<xsl:text>TVA (</xsl:text>
<xsl:value-of select="taux" />
<xsl:text> %)</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of select="format-number(mt_tva, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center" padding="5px"
font-size="10px" font-weight="normal">
Total T.T.C
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right" background-color="white"
border-color="black" border-width="1px" border-style="solid"
font-weight="bold" padding="3px">
<xsl:value-of
select="format-number(/Devis/Corps/Footer/mt_ttc, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body background-color="white" border-color="black"
border-width="1px" border-style="solid">
<xsl:for-each select="Ligne">
<!-- page break -->
<xsl:if test="position() mod 3 = 0">
<fo:table-row break-before="page">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<fo:table-row space-before.optimum="0pt">
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="ref" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="designation" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="center">
<xsl:value-of select="qte" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:value-of select="format-number(pu_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:if test="remise > 0">
<xsl:value-of select="format-number(remise, '### ###.00')" />
</xsl:if>
<xsl:if test="contains(remise, '%')">
<xsl:value-of select="remise" />
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="3px">
<fo:block text-align-last="right">
<xsl:value-of select="format-number(total_ht, '### ###.00')" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:block-container>
</xsl:template>
这是我的 XML 文件的一部分:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Devis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="_dt.xsd">
<Corps>
<Lignes>
<Ligne>
<ref>ASUS97_105</ref>
<designation>produit 1</designation>
<qte>1</qte>
<pu_ht>160</pu_ht>
<remise>34.55</remise>
<total_ht>125.45</total_ht>
</Ligne>
<Ligne>
<ref>FORT1</ref>
<designation>produit 2</designation>
<qte>1</qte>
<pu_ht>60</pu_ht>
<remise>15%</remise>
<total_ht>51</total_ht>
</Ligne>
<Ligne>
<ref>FORT2</ref>
<designation>produit 3</designation>
<qte>1</qte>
<pu_ht>70</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT3</ref>
<designation>produit 4</designation>
<qte>1</qte>
<pu_ht>80</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT4</ref>
<designation>produit 5</designation>
<qte>1</qte>
<pu_ht>70</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
<Ligne>
<ref>FORT5</ref>
<designation>produit 6</designation>
<qte>1</qte>
<pu_ht>80</pu_ht>
<remise></remise>
<total_ht>60</total_ht>
</Ligne>
</Lignes>
<Footer>
<mt_ht>185.45</mt_ht>
<TVA>
<Ligne_TVA>
<mt_tva>37.09</mt_tva>
<taux>20</taux>
</Ligne_TVA>
</TVA>
<mt_ttc>222.54</mt_ttc>
<duree>60</duree>
<Check>
<path>checkbox.png</path>
<path_pdf>file:/D:/checkbox.png</path_pdf>
</Check>
<Commentaire_refus_devis>
<Ligne_commentaire>
<commentaire>commentaire 1
</commentaire>
</Ligne_commentaire>
<Ligne_commentaire>
<commentaire>commentaire 2
</commentaire>
</Ligne_commentaire>
<Ligne_commentaire>
<commentaire>commentaire 3
</commentaire>
</Ligne_commentaire>
</Commentaire_refus_devis>
</Footer>
</Corps>
</Devis>
我的 PDF 文件中没有分页符!
有什么想法吗?
提前致谢
调频
您的 fo:table
在绝对定位的 fo:block-container
中。
Only objects with absolute-position="auto" may have page/column breaks.
For other values any keep and break properties are ignored.
因此,您的分页符被正确地忽略了。
提议的更改:
- 删除
fo:block-container
- 而不是
fo:block-container
上的top="11cm"
,您可以在fo:region-body
上使用margin-top="11cm"
(或在其当前值上增加 11cm)