Python wkhtmltopdf to create pdf

I can create a pdf file using the wkhtmltopdf command line, but when I use it in python lib

from wkhtmltopdf import WKhtmlToPdf wkhtmltopdf = WKhtmlToPdf( url='http://www.wikipedia.org', output_file='a.pdf', ) 

I get

 'Exception: Missing url and output file arguments' 
+7
source share
3 answers

I think there is a problem with the current version. I had the same problems, and if you look at their Github page, someone posted the same problem two days ago.

This should also work, according to their documentation:

 python -m wkhtmltopdf.main google.com ~/google.pdf 

But instead, I get:

optparse.OptionConflictError: option -h/--header-html: conflicting option string(s): -h

Since this is a shell, I assume the main application has been updated, but the wrapper was not.

+1
source
 from wkhtmltopdf import WKhtmlToPdf wkhtmltopdf = WKhtmlToPdf(* [url='http://www.wikipedia.org', output_file='a.pdf'] ) 

2015 is here, but it will work;)

0
source

The problem is a typo and a rewritten API in wkhtmltopdf / main.py

Currently API:

 from wkhtmltopdf import WKhtmlToPdf wkhtmltopdf = WKhtmlToPdf('http://www.wikipedia.org','out.pdf') 
0
source

All Articles