I have the following Python code that I want to use to generate a pdf file. It uses the pdfkit library.
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))
The Resulting PDF is as follows. All I need simply is a line above this is a footer.
According to to the following site, I can add a footer line above the footer using the attribute footer-line
but I'm not understanding the syntax on how to implement it in python
How do I modify the options
attribute to include 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
}
Apparently you just add the attribute and pass it an empty parameter
so to the options
attribute you just add 'footer-line':''
So it becomes the following
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
}
If there is a better way to do it please let me Know