使用pisa/xhtml2pdf在第一页和连续页面上显示不同的页脚

Sam*_*ton 4 footer pisa xhtml2pdf

我在将一个页脚显示为比萨文档的第一页上的一个框架时,以及在每个其他页面上显示为另一个框架时遇到了一些麻烦.我试图从这里调整lastPage的想法,但没有运气.

是否有可能做到这一点?<pdf:nextpage />这似乎不是正确的事情,因为文档有一个可能(或可能不)流过多个页面的长表.<pdf:nextframe />加上只有第一页的框架看起来很有希望,但我不确定如何使用它.

目前我(为了简洁起见):

<style type="text/css">
  @page {
    margin: 1cm;
    margin-bottom: 2.5cm;
    @frame footer {
      -pdf-frame-content: footerFirst;
      -pdf-frame-border: 1;
      bottom: 2cm;
      margin-left: 1cm;
      margin-right: 1cm;
      height: 1cm;
   }
   @frame footer {
      -pdf-frame-content: footerOther;
      bottom: 2cm;
      margin-left: 1cm;
      margin-right: 1cm;
      height: 1cm;
}
</style>
Run Code Online (Sandbox Code Playgroud)
<body>
  <table repeat="1">
    <!-- extra long table here -->
  </table>
  <div id="footerContent">This is a footer</div>
  <!-- what goes here to switch frames after the first page? -->
  <div id="footerOther"></div>
</body>
Run Code Online (Sandbox Code Playgroud)

这会在每个页面上放置相同的页脚.我需要在每个连续页面上留下相同的空间,但框架中没有内容.

Col*_*een 5

您可以按名称定义其他布局,然后告诉xhtml2pdf使用nexttemplate标记显式切换到它们.我最近做了这个,在我的第一页上没有标题,但是在所有后续页面上显示它.

您应该将@page定义更改为两个不同的页面,可能是这样的:

<style type="text/css">
  @page {
    margin: 1cm;
    margin-bottom: 2.5cm;
    @frame footer {
      -pdf-frame-content: footerFirst;
      -pdf-frame-border: 1;
      bottom: 2cm;
      margin-left: 1cm;
      margin-right: 1cm;
      height: 1cm;
   }
 }

 @page innerpages {
   margin: 1cm;
   margin-bottom: 2.5cm;
   @frame footer {
      -pdf-frame-content: footerOther;
      bottom: 2cm;
      margin-left: 1cm;
      margin-right: 1cm;
      height: 1cm;
   }
 }
</style>
Run Code Online (Sandbox Code Playgroud)

然后,在您想要切换到不同布局的html中,使用如下标记:

<pdf:nexttemplate name="innerpages"/>
Run Code Online (Sandbox Code Playgroud)

下一页(以及后续页面,直到您再次更改模板)将使用内页面布局与您的"其他"页脚.

  • @Don:你把最后一页作为自己的模板,并在你准备好时切换到它.如果您尝试将动态内容放到最后一页上,可能会或者可能不会有内容,您可能需要更加花哨.我有一个当前的产品,在输出的行和行之后有一个特殊的最后一页 - 而不是试图将最后一行放到特殊页面上我们只是自己运行最后一页 - 不知道这是否有助于你的情况或不. (2认同)