2

I have searched some method to convert my local html files to pdf file in python. What I searched was pdfkit, weasyprint, xhtml2pdf, pdfcrowd.

The problem is, I should make this as an exe file with Pyinstaller to give someone else so that they can work with this program. And I encountered an OSerror with pdfkit which is saying:

OSError: No wkhtmltopdf executable found: "b''"

And I found the solution that I have to edit some environment variables for that. Weasyprint also need to download/install other things.

I don't think those will work in other PC since they need some external treatment to run the program.

xhtml2pdf seems be the one which convert html from the webpage(not the local file) to pdf, and pdfcrowd is my least option for now since I have to pay to use the API.

Do you have any recommendations for converting those with my circumstances?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Jeong In Kim
  • 373
  • 2
  • 12
  • Does this answer your question? [How to convert a local HTML file to PDF using Python in Windows?](https://stackoverflow.com/questions/48510979/how-to-convert-a-local-html-file-to-pdf-using-python-in-windows) – KetZoomer Jan 10 '21 at 23:02

1 Answers1

-1

Do you actually need to provide a python package thing? Because frankly any modern browser should be able to print to a PDF, and that's significantly simpler than anything else if it suffices: have "someone" open the HTML page in their browser, print it, and select whatever option prints to PDF (save as PDF in chrome, print to file in firefox, ...)

Masklinn
  • 34,759
  • 3
  • 38
  • 57
  • Yes I know. But sadly, my co-worker needs it inside of some kind of crawler I already made. I mean, HTML is enough for store , right? But he insists... something like that. I also told him that after you get all HTML, I can convert it to pdf throughly, but he said he needs to check it by the time to time... That's what makes me to get here. – Jeong In Kim Feb 04 '20 at 09:00
  • Then I fear they'll have to deal with the mess of dependencies of any PDF converter package. wkhtmltopdf is the most widespread but tends to be temperamental, weasyprint is more reliable but IIRC less full-featured. Both are likely a pain to get running on windows but I expect provide instructions. An option might be to provide something like a docker image which sets up all the dependencies but that might not be any easier on windows. – Masklinn Feb 04 '20 at 09:46
  • Ah I was also feared to hear that so :) Thank you for your kind comment Masklinn. I'll deal with my co-worker for this. – Jeong In Kim Feb 04 '20 at 09:47