gpt4 book ai didi

java - 带 Flying Saucer 和 CSS 的分段页数

转载 作者:行者123 更新时间:2023-11-28 15:07:55 24 4
gpt4 key购买 nike

我正在使用 Flying Saucer 从 web HTML 生成 PDF 报告。我的报告包含多个部分,每个部分可能会或可能不会占用报告中的多个页面

我的要求是在页眉中显示章节页数

-----------HEADER-----------
My Fancy Report
First Section (Page 1)
-----------------------------
.
. First Section (conitinued)
.
-----------HEADER-----------
My Fancy Report
First Section (Page 2)
-----------------------------
.
. First Section (Completed)
.
-----------HEADER-----------
My Fancy Report
Second Section (Page 1)
-----------------------------
.
. Second Section
.

我试过使用如下的计数器

header { counter-increment: myCounter; }
header:after{content: ' (Page ' counter(myCounter) ')' ;}
#page{ counter-reset: myCounter; }

#page 是出现在新部分的每个开始处的元素

这样做,我从来没有看到计数器被新部分重置。

似乎 counter-reset 不适用于 Flying Saucer ,这就是我在某处读到的内容。

谁能告诉我实现这一目标的最佳方法是什么?

最佳答案

由于 counter-reset 不能与 Flying-sacuer 一起正常工作,我找到了一个简单的解决方法。希望这会帮助其他人

正如我的问题中提到的,我的文档中有多个正在运行的标题(部分标题)。我为每个部分标题创建一个单独的计数器并独立递增它们。

#sectionOneHeader{ counter-increment: sectionOneCounter; }
#sectionOneHeader:after{ content: ' (Page ' counter(sectionOneCounter) ') '; }

#sectionTwoHeader{ counter-increment: sectionTwoCounter; }
#sectionTwoHeader:after{ content: ' (Page ' counter(sectionTwoCounter) ') '; }

这完全符合我的要求。

关于java - 带 Flying Saucer 和 CSS 的分段页数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49041996/

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