【发布时间】:2017-12-18 20:10:08
【问题描述】:
几天前,我开始使用 PDFKIT,用 Python 生成报告。当我想显示文档的页数时出现了我的问题。我不知道我错过了什么,或者我在哪里失败了。下面是显示的错误、我正在使用的代码以及生成的 pdf。
Error: The switch --footer-right, is not support using unpatched qt, and will be ignored
代码:
import pdfkit
options = {
'page-size': 'Letter',
'margin-top': '1cm',
'margin-right': '1cm',
'margin-bottom': '1cm',
'margin-left': '1cm',
'--footer-right': '[page]',
}
body = u"""
<html>
<head>
<meta name="pdfkit-page-size" content="Letter"/>
<meta name="pdfkit-orientation" content="Portrait"/>
<meta charset="utf-8">
<style>
.td_left{
text-align: left;
}
.td_rigth{
text-align: right;
}
img{
width: 150px;
height: auto;
position: absolute;
top: 0;
left: 0;
}
</style>
</head>
<body>
<img src='/home/produccion/Downloads/logo.png'>
<center>
<h2><b>NOMBRE DE LA EMPRESA - NOMBRE DE LA SUCURSAL</b></h2>
<h3><b>NIT: 000.000.000-0</b></h3>
<h2><b>CONTABILIZACIÓN</b></h2>
<center>
<table>
<thead>
<th>CUENTA PUC</th>
<th>BOD</th>
<th class='td_left'>TERCERO</th>
<th class='td_rigth'>DOC N°</th>
<th class='td_rigth'>VENCE</th>
<th class='td_rigth'>CANTIDAD</th>
<th class='td_rigth'>DÉBITO</th>
<th class='td_rigth'>CRÉDITO</th>
</thead>
<tbody>
"""
for i in range(15):
body += """<tr>
<td>0000-00-000</td>
<td>{0}</td>
<td class='td_left'>NOMBRE DEL TERCERO</td>
<td class='td_rigth'>AAA0000000001</td>
<td class='td_rigth'>01/01/2000</td>
<td class='td_rigth'>0.0</td>
<td class='td_rigth'>00000000</td>
<td class='td_rigth'>00000000</td>
</tr>""".format(i+1)
body += """</tbody>
</table>
</body>
</html>"""
pdfkit.from_string(body, 'ejemplo.pdf', options=options)
结果:
【问题讨论】:
-
在以下链接中,您将找到答案/en el siguiente enlace encontraran la respuesta:see answer - ver respuesta
-
好吧,因为我没有找到可以回答我的问题的人,经过几个小时的研究,我找到了解决我提出的这个不便的方法,第一件事就是拥有了解我已安装的 wkhtmltopdf 版本,在我的情况下是:“0.12.4”没有(已修补的 qt),所以我的解决方案是返回到“wkhtmltopdf 0.12.3”版本(已修补的 qt )"
标签: python qt python-pdfkit