背景信息
我有下面的Python代码,我想用来生成一个pdf文件。它使用pdfkit库。
import pdfkit # import python module
if __name__=="__main__":
options = {
'page-size': 'Letter',
'margin-top': '0.5in',
'margin-right': '0.75in',
'margin-bottom': '0.5in',
'margin-left': '0.75in',
'encoding': "UTF-8",
'footer-left': "This is a footer",
'footer-font-size':'7',
'footer-right': '[page] of [topage]',
'custom-header' : [
('Accept-Encoding', 'gzip')
],
'no-outline': None
}
##this is the path of the whkhtmltopdf.exe in order for the library to
##work on a Windows OS
path_wkthmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
pdfkit.from_url('http://google.com', 'Report.pdf',options=options,configuration=config))得到的PDF如下。我只需要一条线以上,这是一个页脚。

根据下面的站点,我可以使用属性footer-line在页脚上方添加页脚行,但我不了解如何在python中实现它的语法。
简短的问题
如何修改options属性以包括footer-line
options = {
'page-size': 'Letter',
'margin-top': '0.5in',
'margin-right': '0.75in',
'margin-bottom': '0.5in',
'margin-left': '0.75in',
'encoding': "UTF-8",
'footer-left': "This is a footer",
'footer-font-size':'7',
'footer-right': '[page] of [topage]',
'custom-header' : [
('Accept-Encoding', 'gzip')
],
'no-outline': None
}发布于 2017-08-03 08:02:00
显然,您只需添加属性并将其传递给一个空参数。
因此,对于options属性,您只需添加'footer-line':'',它将变成以下内容
options = {
'page-size': 'Letter',
'margin-top': '0.5in',
'margin-right': '0.75in',
'margin-bottom': '0.5in',
'margin-left': '0.75in',
'encoding': "UTF-8",
'footer-left': "This is a footer",
'footer-line':'',
'footer-font-size':'7',
'footer-right': '[page] of [topage]',
'custom-header' : [
('Accept-Encoding', 'gzip')
],
'no-outline': None
}如果有更好的方法,请告诉我
https://stackoverflow.com/questions/45478048
复制相似问题