Reputation: 339
From an XML file (originally a Word file) I create a PDF with XSLT and XSLFO. Bold font is to be adopted. This works, but the PDF contains unwanted spaces in the bold words (see "unwanted result"). The reason is that fo:inline
creates spaces within fo:block
(Word incomprehensibly splits some words into several w:t
elements). The renderer is FOP.
I have no idea how to turn it off that the white space is generated. I have already tried some white space settings, like xsl:strip-space elements
and white-space-collapse
, but without success.
Why does the stylesheet create white space between fo:inline
and how can I fix this?
Unwanted Result
from the PDF: "... weil Fi l mmaterial in der ..."
Wanted Result
It should be: "... weil Filmmaterial in der ..."
SOURCE, shortened by some elements (which are not crucial) for the sake of clarity
<div class="listlevel-1">
<w:p>
<w:r>
<w:t>... weil </w:t>
</w:r>
<w:r>
<w:t>Fi</w:t>
</w:r>
<w:r>
<w:t>l</w:t>
</w:r>
<w:r>
<w:t>mmaterial</w:t>
</w:r>
<w:r>
<w:t> in der digitalen ...</w:t>
</w:r>
</w:p>
</div>
XSLT-Stylesheet, shortened by some elements (which are not crucial) for the sake of clarity
2 XSLT stylesheets intertwine during the transformation. The problem occurs within lists. One stylesheet transforms lists (1), the second transforms all text elements (w:t elements) that are bold, italic or underlined.
1)
<xsl:template match="//div[@class = 'listlevel-1']/w:p">
<fo:list-item xsl:use-attribute-sets="listitem">
<fo:list-item-label xsl:use-attribute-sets="itemlabel">
<fo:block>•</fo:block>
</fo:list-item-label>
<fo:list-item-body xsl:use-attribute-sets="itembody">
<fo:block>
<xsl:apply-templates select="w:r/w:t"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
Several xsl:choose
branches are used to query several conditions; conditions 2 and 3 are not listed here because of their length, but they are structured exactly like condition 1.
<xsl:template match="//w:t">
<xsl:choose>
<xsl:when test="../w:rPr/w:b">
<xsl:choose>
<xsl:when test="../w:rPr/w:u">
<xsl:choose>
<xsl:when test="../w:rPr/w:i">
<fo:inline>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="text-decoration">underline</xsl:attribute>
<xsl:attribute name="font-style">italic</xsl:attribute>
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="text-decoration">underline</xsl:attribute>
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
...
</xsl:choose>
</xsl:template>
FO-File, what the code looks like in the FO file:
<fo:block>... weil
<fo:inline font-weight="bold">Fi</fo:inline>
<fo:inline font-weight="bold">l</fo:inline>
<fo:inline font-weight="bold">mmaterial</fo:inline> in ...
</fo:block>
Upvotes: 3
Views: 390
Reputation: 4834
Maybe you used: <xsl:output indent="yes" />
.
If so, change that to <xsl:output indent="no" />
And if your source is already indented, use: <xsl:strip-space elements="w:r"/>
Upvotes: 2