Html 从XSL-FO生成的PDF中不需要的换行符?
我正在使用XSLT将一些HTML转换为PDF。我得到一些不必要的断线,我不知道为什么 以下是HTML源代码:Html 从XSL-FO生成的PDF中不需要的换行符?,html,xml,pdf,xslt,xsl-fo,Html,Xml,Pdf,Xslt,Xsl Fo,我正在使用XSLT将一些HTML转换为PDF。我得到一些不必要的断线,我不知道为什么 以下是HTML源代码: <li><strong>must</strong> only work in the occupation and for the sponsor with the most recently approved nomination for the holder <strong>unless</strong>
<li><strong>must</strong> only work in the occupation and for
the sponsor with the most recently approved nomination for
the holder <strong>unless</strong> the visa holder's
occupation is specified on a relevant instrument;
</li>
必须仅在该职业和
最新获得批准提名的赞助商
持有人除非签证持有人的
相关文书上规定了职业;
下面是它在浏览器中的外观:
以下是一些XSLT:
<xsl:template match="condition/div">
<xsl:apply-templates select="div|p|ul|li|a|ol|strong"/>
</xsl:template>
<xsl:template match="li" mode="bullet">
<fo:list-item>
Unicode Bullet Character
<fo:list-item-label end-indent="label-end()">
<fo:block>
•
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="8pt" padding-bottom="2mm" padding-top="1mm">
<xsl:apply-templates />
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<xsl:template match="strong">
<fo:block font-weight="bold">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
Unicode项目符号字符
•;
…以下是输出结果:
如您所见,不需要的换行符出现在
标记之后。有什么办法阻止这种情况发生吗?你想在这里(比如HTML中的span
),而不是(比如HTML中的div
)
改变
<xsl:template match="strong">
<fo:block font-weight="bold">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
到
要消除
strong
之后的换行符,我喜欢Stackoverflow,我喜欢kjhughes.)
<xsl:template match="strong">
<fo:inline font-weight="bold">
<xsl:value-of select="." />
</fo:inline>
</xsl:template>