gpt4 book ai didi

xsl-fo - 如何指示 fo :block spans a page

转载 作者:行者123 更新时间:2023-12-02 02:25:59 25 4
gpt4 key购买 nike

我有一个 fo:block 可能跨越一个页面。我想在该 block 所在的第一页的底部放置一些文本,例如“继续”。

源文档在 标记内有一系列

我认为做到这一点的唯一方法是在源文档的正确位置添加 下一页继续 ,但这需要在编写文档时不断进行编辑。

是否可以测试某个 block 是否跨越页面?

源文档:

<recipe page-break="auto">
<instructions>
<step>The first thing to do</step>
<step>The second thing to do</step>
</instructions>
<recipe>

样式表的相关部分:

<xsl:template match="recipe">
<xsl:variable name="pbi"><xsl:choose><xsl:when test="@page-break"><xsl:value-of select="@page-break"/></xsl:when><xsl:otherwise>avoid</xsl:otherwise></xsl:choose></xsl:variable>
<xsl:variable name="pbb"><xsl:choose><xsl:when test="@page-break">always</xsl:when><xsl:otherwise>auto</xsl:otherwise></xsl:choose></xsl:variable>
<fo:block page-break-inside="{$pbi}" page-break-before="{$pbb}" margin-bottom="1.5em">
<xsl:apply-templates select="instructions/step" mode="plain"/>
</fo:block>
</xsl:template>

谢谢。

最佳答案

虽然托尼的建议可行,但它仅适用于支持该构造的格式化程序。正如他所建议的,您可以将纯标记拉入页脚中,以实现相同的效果。您可能对内容末尾和页脚之间的垂直空间控制较少,但这取决于您的内容。

您只需在页脚区域使用检索标记,例如:

    <fo:static-content flow-name="footer">
<fo:block-container text-align="left" margin-left="1in">
<fo:block><fo:retrieve-marker retrieve-class-name="continued" retrieve-boundary="page" retrieve-position="last-starting-within-page"/>
</fo:block>
</fo:block-container>
</fo:static-content>

现在,在您的流程中,您有一些 block ,您希望当该 block 中断页面时在其中显示消息。你使用这样的东西:

 <fo:block-container>
<fo:marker marker-class-name="continued">I am continued on next page ...</fo:marker>
<fo:block margin-top="6pt">I am some text that will break across the page somewhere. When I do break the footer should have continued. I am some text that will break across the page somewhere. When I do break the footer should have continued. </fo:block>
<!-- More content here, whatever you need -->

</fo:block-container>
<fo:block-container keep-with-previous.within-page="always">
<fo:marker marker-class-name="continued"></fo:marker>
</fo:block-container>

block 容器内的第一个标记将创建一个带有您想要的连续文本的“标记”。如果页面在该 block 内中断,则标记将被拉入页脚区域。第二个标记有效地“清除”它,因为它没有内容。它被拉到页脚,但它是空白的,所以什么也没有出现。

结果是这样的,不存在连续的文本(第 1、3、4 页),除非在标有连续消息的区域内分页(第 2 页)。

enter image description here

关于xsl-fo - 如何指示 fo :block spans a page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56267273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com