当前位置: 首页 > 知识库问答 >
问题:

Apache FOP 2.2->2.3,分页

周学义
2023-03-14

我在将FOP从2.2版迁移/升级到2.3版时遇到了一个问题。分页器停止工作…这是示例代码:

主要“模板”:

<xsl:stylesheet 
version="1.1" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<fo:page-sequence 
    master-reference="templates/A4.xsl" 
    initial-page-number="1" 
    font-size="9pt" 
    font-weight="plain"
    font-family="Arial"
>

    <section id="footer" filename="templates/ftr_PgNmb.xsl" />

    <fo:flow flow-name="xsl-region-body">

        <fo:block >Page 1</fo:block>

        <fo:block page-break-before="always"/>
        <fo:block >Page 2</fo:block>

        <fo:block page-break-before="always"/>
        <fo:block>Page 3</fo:block>

        <fo:block id="last-page" />

    </fo:flow>

</fo:page-sequence>

寻呼机1:

<xsl:stylesheet version="1.1" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo"
>
<xsl:apply-templates select="templates/ftr_PgNmbTemplate.xsl"/>

分页器2:

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:template match="templates/ftr_PgNmbTemplate.xsl">  
<fo:static-content flow-name="xsl-region-after-firstpage">
    <fo:block>
        <fo:table table-layout="fixed" width="100%" border-collapse="separate">
            <fo:table-column />
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block text-align="right">
                            Page <fo:page-number /> of <fo:page-number-citation-last ref-id="last-page"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after-otherpages">
    <fo:block>
        <fo:table table-layout="fixed" width="100%" border-collapse="separate">
            <fo:table-column/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block text-align="right">
                            Page <fo:page-number /> of <fo:page-number-citation-last ref-id="last-page"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:block>
</fo:static-content>

</xsl:template>

我得到的错误是:

严重:序列化页面1时出错。原因:java.io。NotSerializableException:org.apache.fop.fo.pagination。PageSequence java.io。NotSerializableException:org.apache.fop.fo.pagination。java.io.ObjectOutputStream上的PageSequence。writeObject0(未知源)

有什么提示吗?我一点头绪都没有。我发现的是问题出在

编辑:完成生成xsl:

java.io.NotSerializableException: org.apache.fop.fo.pagination.PageSequence

共有1个答案

钱宇
2023-03-14

根据FOP关于FO的帮助页面:

...若要在 XSL 1.0 中完成此操作,请在流的末尾放置一个带有 id 的空块:

<fo:flow ...>
  ...
  <!-- block, NOT page-sequence -->
  <fo:block id="last-page"/>
</fo:flow>

按如下方式获取最后一页的编号:

<!-- page-number-citation, NOT page-number-citation-last !!! -->
<fo:page-number-citation ref-id="last-page"/>

这在某些情况下不起作用:多个页面序列、初始页码不是1,或者强制某个页面计数,从而在末尾产生空白页面。

在XSL 1.1中,有另一个选项可以做到这一点:确保在页面序列上设置了一个“id”,并使用fo:page-number-citation -last引用它。首先,页面顺序:

<!-- page-sequence, NOT block-->
<fo:page-sequence id="seq1" ...

之后,引用页面序列生成的最后一页:

<!-- page-number-citation-last, NOT page-number-citation !! -->
<fo:page-number-citation-last ref-id="seq1"/>

警告:没有可靠的方法可以使用FO机制获得实际的总页数。您只能获得页码。

因此,在您的情况下,请:

> < li >更改<代码>

<fo:page-number-citation-last ref-id="last-page"/>`
 类似资料:
  • 2.3 路径分析 路径分析通过抽象用户在网站中的访问行为轨迹,并用可视化图表呈现,帮助使用者了解用户在网站上的流动情况。 全路径图 以某个页面/事件为起点进行分析的路径图,帮助我们了解用户从某个起点开始的行为轨迹。 时间维度:今日之前,最大时间周期可选择1个月; 选择分析对象:可选择起始浏览页面or起始互动事件作为分析对象; 起始浏览页面:以网站的某个网页作为分析起点,分析用户之后到过哪些网页;

  • 2.3 路径分析 路径分析通过抽象用户在网站中的访问行为轨迹,并用可视化图表呈现,帮助使用者了解用户在网站上的流动情况。 全路径图 以某个事件为起点进行分析的路径图,帮助我们了解用户从某个起点开始的行为轨迹。 时间维度:今日之前,最大时间周期可选择1个月; 选择分析对象:可选择起始互动事件作为分析对象; 起始互动事件:以用户在网站上发生的某个互动行为(如“注册”、“登录”、“浏览商品”等)作为分起

  • 固件( Firmware )就是写入 EROM(可擦写只读存储器)或 EEPROM (电可擦可编程只读存储器)中的程序,修改固件是在提取出固件之后,一般是 16 进制的 BIN 文件或者 HEX 文件,然后通过逆向分析或解包之后,获得实际的逻辑代码,然后根据需求修改其中的关键代码,之后再重打包刷回芯片中,使硬件执行修改之后的固件。

  • 对于已经创建好的地图,你可以把它分享给其他用户浏览,其他用户无需注册或登录就可以访问您分享的内容。当然这些用户无法对分享的结果进行修改。 分享按照权限分五种。系统默认是不分享,其次是通过访问密码,以及任何人都可以访问,第四个分享适用于嵌入网站和博客的代码复制,第五种分享选中后,则会在地图者主页面的分享中心进行展示。 你可以把地图分享链接,发送到微信,微博等供他人快速访问。 注意:你需要单击保存按钮

  • 在Android Studio更新到2.3后,我得到以下错误。 错误:无法加载类“org.gradle.logging.StyledTextOutput”。此意外错误的可能原因包括: null null

  • 完整的破坏性改动列表请到这里查看:breaking change issues. 空的泛型列表会被标记为错误 示例 class X<> {} // Error: Type parameter list cannot be empty. function f<>() {} // Error: Type parameter list cannot be empty. const x: X<> =