gpt4 book ai didi

html - 最后一页的页脚,同时通过 Flying Saucer 生成 pdf

转载 作者:太空狗 更新时间:2023-10-29 12:34:50 25 4
gpt4 key购买 nike

我正在使用 flaying saucer java 库。

我正在尝试向我生成的 pdf 添加页脚。

目标是每页页脚相同,最后一页内容不同。

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>

我为此苦苦挣扎了几天,在网上找到的任何建议都不够好。

我正在尝试

@page:last {} 

或与:

@bottom-left {
content: element(footer_one, last-except);
}

@bottom-right{
content: element(footer_two, last-except);
}

但似乎 :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>

关于html - 最后一页的页脚,同时通过 Flying Saucer 生成 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22147916/

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