Cfr*_*eak 5 css python xhtml2pdf
希望有人可以解决这个问题。在 Google 上还没看到有人用过它。
我在 Python 中使用 xhtml2pdf,尝试生成一个带有页眉、页脚的简单文档,我的内容是带有标题的文本块。我希望在每个内容周围都有边框,但我却在每个子元素周围都有边框。
这是我的 HTML
@page {
size: letter;
border: 0;
@frame header_frame {
-pdf-frame-content: header;
border: 0pt solid white;
left: .75in;
width: 7in;
top: .5in;
height: 1.5in;
}
@frame content_frame {
border: 0pt solid white;
left: .75in;
width: 7in;
top: 1.5in;
height: 7.5in;
}
@frame footer_frame {
-pdf-frame-content: footer;
border: 0pt solid white;
left: .75in;
width: 7in;
top: 9.5in;
height: 1in;
}
}
h1 {
padding-top: 5pt;
}
.desc {
margin-top: 3px;
margin-bottom: 3px;
padding: 3px;
border: 1px solid blue;
}Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>TEST TEST TEST</title>
</head>
<body>
<div id="header">
<h1>HEADER</h1>
</div>
<div id="footer">
FOOTER
</div>
<div class="desc">
<div class="title">TITLE OF ARTICLE</div>
<span>TEST 2</span>
<div>TEST 3</div>
<table>
<tr>
<td>Test4</td>
<td>Test 5</td>
</tr>
</table>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
xhtml2pdf我现在只是运行命令行工具,所以没有 python 可以显示。我注意到的一件事是,当我在调试模式下运行它时,它显示“xhtml = false”,即使我有 XHTML DTD。我不确定这是否会有所作为。
这是我在浏览器中看到的内容以及我期望的 pdf 的大致样子(当然忽略页脚位置):

相反,我得到:

编辑:我发现 xhtml 是一个可以通过的选项,但除非安装了旧版本的 html5lib,否则传递它会失败。看起来我的问题的答案是这个库没有得到积极维护,我需要找到一个新的解决方案:-/
| 归档时间: |
|
| 查看次数: |
1248 次 |
| 最近记录: |