使用 pisa/xhtml2pdf 在第一页和连续页上显示不同的页脚
我在让页脚在 Pisa 文档的第一页上显示为一个框架,并在每个其他页面上显示为另一个框架时遇到一些问题。我尝试改编此处的lastPage想法,但没有成功。
可以这样做吗?
在这里似乎不是正确的事情,因为文档有一个很长的表格,可能(或可能不)跨越多个页面。
加上仅首页框架看起来很有希望,尽管我不确定如何准确使用它。
目前我有(为了简洁而剪掉):
<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>
<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>
这会在每个页面上放置相同的页脚。我需要在每个连续页面上留下相同的空间,但框架中没有内容。
I'm having some trouble getting a footer to appear as one frame on the first page of a Pisa document, and as another frame on every other page. I have attempted to adapt the lastPage idea from here, but with no luck.
Is it possible to do this? <pdf:nextpage />
doesn't seem to be the right thing here since the document has a long table that may (or may not) flow over multiple pages. <pdf:nextframe />
plus a first-page-only frame looks promising, though I'm not sure how to use this exactly.
Currently I have (snipped for brevity):
<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>
<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>
This places the same footer on each page. I need the same space left on each consecutive pages, but with no content in the frame.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以按名称定义其他布局,然后告诉 xhtml2pdf 使用 nexttemplate 标记显式切换到它们。我最近正是这样做的,在我的第一页上没有标题,但在所有后续页面上显示它。
您应该将 @page 定义更改为两个不同的页面,也许像这样:
然后,在您想要切换到不同布局的 html 中,使用如下标记:
下一页(以及后续页面,直到您再次更改模板)将使用内页布局与“其他”页脚。
You can define additional layouts by name, then tell xhtml2pdf to switch to them explicitly using the nexttemplate tag. I did exactly this recently to have no header on my first page but to show it on all the subsequent pages.
You should change your @page definition to two different pages, perhaps like this:
Then, in your html where you want to switch to the different layout, use a tag like this:
The next page (and subsequent pages until you change the template again) will use the innerpages layout with your 'other' footer.