Welcome to headless_pdfkit’s documentation!¶
Headless PDFKit¶
The PDFKit package makes use of wkhtmltopdf
, which in turn needs an X Server
to run. In Debian land, this generally requires xvfb-run
wrapper.
The headless_pdfkit
package tries to make the hotfix proposed by
jakewins a bit easier to work with.
Examples¶
Save a simple PDF from string.:
from headless_pdfkit import generate_pdf
ret = generate_pdf('<html></html>')
with open('output.pdf', 'wb') as w:
w.write(ret)
Save a simple PDF from string while passing the –auto-servernum
parameter to xvfb-run
.:
options = {
'auto_servernum': ''
}
ret = generate_pdf('<html></html>', options=options)
with open('output.pdf', 'wb') as w:
w.write(ret)