您好,登錄后才能下訂單哦!
問題:python3 如何轉(zhuǎn)換html到pdf
描述:
我的電腦是windows764位,python3.4
我想用python 轉(zhuǎn)換html到pdf.
我嘗試了html2pdf,貌似它只支持Python2
我又嘗試了wkhtmltox-0.12.2.2_msvc2013-win64和pdfkit,并用下面的例子測試。
import pdfkit pdfkit.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”的問題解答,希望對(duì)有需要的網(wǎng)友有所幫助。
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)億速云的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。