相关疑难解决方法(0)

XSL-FO:对表条目强制换行

当我将modspecs发布到pdf(XSL-FO)时,我遇到了一个问题.我的表存在问题,其中单元格的内容会将其列溢出到下一个列中.如何强制中断文本以便创建新行?

我无法手动插入零空格字符,因为以编程方式输入表条目.我正在寻找一个简单的解决方案,我只需添加到docbook_pdf.xsl(作为xsl:param或xsl:属性)

编辑: 这是我目前的地方:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="urn:docbkx:stylesheet"/>
...(the beginning of my stylesheet for pdf generation, e.g. header and footer content stuff)
<xsl:template match="text()">
    <xsl:call-template name="intersperse-with-zero-spaces">
        <xsl:with-param name="str" select="."/>
    </xsl:call-template>
</xsl:template>
<xsl:template name="intersperse-with-zero-spaces">
    <xsl:param name="str"/>
    <xsl:variable name="spacechars">
        &#x9;&#xA;
        &#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;
        &#x2006;&#x2007;&#x2008;&#x2009;&#x200A;&#x200B;
    </xsl:variable>

    <xsl:if test="string-length($str) &gt; 0">
        <xsl:variable name="c1" select="substring($str, 1, 1)"/>
        <xsl:variable name="c2" select="substring($str, 2, 1)"/>

        <xsl:value-of select="$c1"/>
        <xsl:if test="$c2 != '' and
            not(contains($spacechars, $c1) or
            contains($spacechars, $c2))">
            <xsl:text>&#x200B;</xsl:text>
        </xsl:if>

        <xsl:call-template name="intersperse-with-zero-spaces">
            <xsl:with-param name="str" select="substring($str, 2)"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template> …
Run Code Online (Sandbox Code Playgroud)

xml pdf xslt xsl-fo

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

pdf ×1

xml ×1

xsl-fo ×1

xslt ×1