When you start to use python pdfkit library to convert a html to pdf in win 10, you may find OSError: No wkhtmltopdf executable found. In this tutorial, we will introduce you how to fix this error.
If you have read how to install wkhtmltopdf in here.
https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
You may notice, if the system is window system, you shoud add wkhtmltopdf folder to system environment. However, i will tell you this method does not work.
How to fix this error?
Find the installation path of wkhtmltopdf.exe
As to us, this path is: C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe
Set pdfkit configuration
config = pdfkit.configuration(wkhtmltopdf='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe')
Convert html to pdf
pdfkit.from_url('https://www.tutorialexample.com', 'out-test.pdf', configuration=config)
Then you will find this error is fixed.
Dear Sir
Hi
Thanks for the solution (Fix OSError: No wkhtmltopdf executable found in Win 10 for pdfkit Beginner – Python pdfkit Tutorial)
But I have a query when I fix this error my app can’t load into the browser. I wait a lot but my app can’t load into the browser.
I also post this problem into StackOverflow but no one gives me the right answer. (https://stackoverflow.com/questions/66418180/convert-html-table-into-pdf-using-flask)
I have checked your question:
1. When I add wkhtmltopdf configuration the page can’t load into the browser.
2. when I remove wkhtmltopdf configuration from my app then my all routes work fine only when i click on the pdf then its give in error.
It means your application may be running pdfkit when loading home page, which is not a good way to convert html to pdf. You should check your application to avoid to run pdfkit when loading pages.
Meanwhile, your app can not load pdfkit into the browser, you should write a test page to test whether pdfkit can be loaded and run by brower.
thanks alot it worked for mee
Thanks for solution , its worked for me