我正在使用 dompdf 0.6.0 生成 pdf 文档,并且遇到一个奇怪的问题,即最后创建了一个空白页面。我的(简化的)html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>PDF</title>
<style type="text/css">
@page{ margin: 0;}
.page{
width: 612px;
height: 792px;
overflow: hidden;
font-family: Arial, Helvetica;
position: relative;
color: #545554;
page-break-after: always;
}
</style>
</head>
<body>
<div class="page" style="background-image: url(page1.jpg);">
...
</div>
<div class="page" style="background-image: url(page2.jpg);"></div>
<div class="page" style="background-image: url(page3.jpg); color: white;">
...
</div>
</body>
</html>
前三页看起来很神奇,但最后有一张空白页。我读过 dompdf 对嵌套和合规性等很挑剔,但 html 非常干净并且可以检查。
结果结局</body>
and </html>
标签导致了额外的页面。我删除了它们,结果正如预期的那样。
我想象这是 dompdf 的问题,但我花了很长时间试图解决这个问题,并认为这可能对其他人有帮助。
Update:
正如乔在评论中提到的,移动</body>
and </html>
标签与结束语位于同一行</div>
有效,并且保持有效的 html。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)