python wkhtmltopdf to Generate pdf
Asked Answered
N

2

9

I am able to generate the pdf using the Command Line wkhtmltopdf 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'
Nigrosine answered 30/8, 2012 at 10:8 Comment(2)
Your code seems quite different from the example included in the github repo.Ramsay
I Used the Example from pypi.python.org/…Nigrosine
C
2

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

This should have worked also, 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 it's a wrapper, I'm guessing the underlying application was updated, but the wrapper has not been.

Cross answered 1/9, 2012 at 2:20 Comment(1)
Calling the class like this seems to get past the error, but other errors reveal themselves: "wkhtmltopdf = WKhtmlToPdf('wikipedia.org','a.pdf',)"Cambrel
A
0

The problem in typos and rewrited API in wkhtmltopdf/main.py

Right now API is:

from wkhtmltopdf import WKhtmlToPdf

wkhtmltopdf = WKhtmlToPdf('http://www.wikipedia.org','out.pdf')
Addams answered 16/4, 2017 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.