【发布时间】:2015-03-25 14:23:14
【问题描述】:
<xsl:template match="PrintingImages">
<fo:block keep-together.within-page="always">
<fo:table table-layout="fixed" width="100%" border-collapse="separate" border-separation="2pt" column-width="50pt">
<fo:table-body>
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</fo:table-body>
</fo:table>
<xsl:template match='PrintImagesData'>
<fo:table-cell>
<fo:block keep-together.within-page="always" float="left">
<xsl:if test="Title">
<fo:block><xsl:value-of select="Title" /></fo:block>
</xsl:if>
<xsl:if test="DateCreated">
<fo:block><xsl:value-of select="DateCreated" /></fo:block>
</xsl:if>
<fo:block line-stacking-strategy="max-height">
<xsl:element name="fo:external-graphic">
<xsl:attribute name="width"><xsl:value-of select="Width"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="Height"/></xsl:attribute>
<xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
<xsl:attribute name="content-height">scale-down-to-fit</xsl:attribute>
<xsl:attribute name="scaling">uniform</xsl:attribute>
<xsl:attribute name="src">url('<xsl:value-of select="ImgData"/>')</xsl:attribute>
</xsl:element>
</fo:block>
</fo:block>
在后端我调用PrintImagesData 4 次,在PDF 中,它在同一行生成四个图像。我想要每行两个图像(例如两行,两列)。我该怎么做?
【问题讨论】:
-
您能否向我们提供输入 XML 以及您的 XSLT 的更多内容?看来你没有插入几个
<fo:table-row> -
如果您使用支持浮动的渲染器,请使用浮动。如果尺寸正确,它们将每行堆叠两个。不需要桌子。
-
在此处查看答案:stackoverflow.com/questions/24311352/…。这是下面答案的替代方法,您不需要为表格抛出行。