問(wèn)題:python3 如何轉(zhuǎn)換html到pdf
描述:
我的電腦是windows764位,python3.4
我想用python 轉(zhuǎn)換html到pdf.
我嘗試了html2pdf,貌似它只支持Python2
我又嘗試了wkhtmltox-0.12.2.2_msvc2013-win64和pdfkit,并用下面的例子測(cè)試。
import pdfkitpdfkit.from_url('http://google.com', 'out.pdf')報(bào)錯(cuò)信息
Traceback (most recent call last): File "E:/Python34/lib/site-packages/pdfkit/configuration.py", line 21, in __init__ with open(self.wkhtmltopdf) as f:FileNotFoundError: [Errno 2] No such file or directory: b''During handling of the above exception, another exception occurred:Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> pdfkit.from_url('http://google.com', 'out.pdf') File "E:/Python34/lib/site-packages/pdfkit/api.py", line 22, in from_url c File "E:/Python34/lib/site-packages/pdfkit/pdfkit.py", line 38, in __init__ self.configuration = (Configuration() if configuration is None File "E:/Python34/lib/site-packages/pdfkit/configuration.py", line 27, in __init__ 'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)OSError: No wkhtmltopdf executable found: "b''"If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf請(qǐng)大神們告訴我,該怎么做呢?
解決方案1:
直接使用里邊的wkhtmltopdf即可
wkhtmltopdf http://google.com a.pdf
解決方案2:
把可執(zhí)行文件的路徑加入到環(huán)境變量里
以上介紹了“python3 如何轉(zhuǎn)換html到pdf”的問(wèn)題解答,希望對(duì)有需要的網(wǎng)友有所幫助。
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)VEVB武林網(wǎng)的支持。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注