【问题标题】:Sectional page count with flying saucer and css使用飞碟和 css 的分段页数
【发布时间】:2018-03-01 03:07:08
【问题描述】:

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

我的要求是在 Header

中显示部分页数
-----------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 不适用于飞碟,这是我在某处读到的。

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

【问题讨论】:

    标签: java html css pdf flying-saucer


    【解决方案1】:

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

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

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

    这正是我想要的方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-05
      • 1970-01-01
      • 2013-11-20
      • 1970-01-01
      • 2014-05-29
      • 2013-07-30
      相关资源
      最近更新 更多