Html 飞碟生成pdf时最后一页的页脚
我正在使用flayingdiscerjava库 我正在尝试将页脚添加到生成的pdf中 目标是在每一页上有相同的页脚,在最后一页上有不同的内容Html 飞碟生成pdf时最后一页的页脚,html,css,pdf-generation,flying-saucer,Html,Css,Pdf Generation,Flying Saucer,我正在使用flayingdiscerjava库 我正在尝试将页脚添加到生成的pdf中 目标是在每一页上有相同的页脚,在最后一页上有不同的内容 html> <head> <style type="text/css"> @page { size: 8.5in 11in; margin-bottom: 1in; @bottom-left { cont
html>
<head>
<style type="text/css">
@page {
size: 8.5in 11in;
margin-bottom: 1in;
@bottom-left {
content: element(footer_one);
}
@bottom-right{
content: element(footer_two);
}
@bottom-center{
content: element(footer_rights);
}
}
#footer_two {position: running(footer_two); }
#footer_one {position: running(footer_one); }
#footer_three {position: running(footer_three);}
#footer_two, #footer_one, #footer_three { margin: 0 padding:0;}
#footer_three { border-top: 2px solid #3390FF;}
</style>
</head>
<body>
<div id="footer_one">
some text short text about three words, on each page
</div>
<div id="footer_two">
some text short text, like page numbers etc, on each page
</div>
<div>
Whole body content
</div>
<div id="footer_three">
some text looooooooonnnnnnnnnggggggggg text, some about ten rows. Only on last page
</div>
</body>
或与:
@bottom-left {
content: element(footer_one, last-except);
}
@bottom-right{
content: element(footer_two, last-except);
}
但看起来:最后一个伪选择器不起作用
最好的方法是在最后一页上有完全不同的一个页脚,其中包括这三个页脚的内容。
我只能在最后一页添加页脚,但我不能禁用前几页的简单页脚
也许还有别的办法?
我将非常感谢您的帮助 如果您事先知道最后一页将显示什么,您可以使用 例如:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.newpage{page-break-before:always}
@page {@bottom-center {content: element(footer)}}
#footer {position: running(footer);}
@page last {@bottom-center {content: element(lastfooter)}}
#lastfooter{position: running(lastfooter);}
#lastpage {page:last}
}
</style>
</head>
<body>
<div id="footer">Footer for all pages except last one</div>
<div id="lastfooter">Footer for last page</div>
<div>Content for all pages except last one</div>
<div class="newpage" id="lastpage">Last page content</div>
</body>
</html>
.newpage{之前的分页符:始终}
@页面{@底部中间{内容:元素(页脚)}
#页脚{位置:运行(页脚);}
@最后一页{@bottomcenter{content:element(lastfooter)}
#lastfooter{位置:正在运行(lastfooter);}
#最后一页{page:last}
}
除最后一页外的所有页的页脚
最后一页的页脚
除最后一页外的所有页面的内容
最后一页内容
试试这个:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>last footer</title>
<style type="text/css">
div.pdf-footer {
padding-top: 4pt;
position: running(footer);
}
@page {
@bottom-center {
content: element(footer, last);
}
}
</style>
</head>
<body>
<div class="pdf-footer">all pages except last</div>
<div>content</div>
<div class="pdf-footer">only last page</div>
</body>
</html>
最后一页脚
div.pdf-footer{
垫面:4吨;
位置:运行(页脚);
}
@页面{
@底部中心{
内容:元素(页脚,最后一个);
}
}
除最后一页外的所有页面
内容
只有最后一页
不幸的是,所有内容都是动态的。我不知道最后一页会是什么,很抱歉。由于没有page:last
选择器,我看不到任何解决您问题的方法。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>last footer</title>
<style type="text/css">
div.pdf-footer {
padding-top: 4pt;
position: running(footer);
}
@page {
@bottom-center {
content: element(footer, last);
}
}
</style>
</head>
<body>
<div class="pdf-footer">all pages except last</div>
<div>content</div>
<div class="pdf-footer">only last page</div>
</body>
</html>