4
votes

Hi I have looked through all similar posts and implemented the suggestions but still no luck.

Running Python, PDFKIT, Windows 7, Google App Engine.

I get this error when trying to run the program

IOError: No wkhtmltopdf executable found: "C:/Users/nb198011/Documents/Shillan/Personal/Installs/wkhtmltopdf/bin/wkhtmltopdf.exe"

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

I have confirmed the file is indeed in that location using the "where" command and I can execute the wkhtmltopdf program from the command line.

I import PDFKIT into my program by holding it in the same folder as my project and wkhtmltopdf is installed into the folder specified in the error message

Any new suggestions would be greatly appreciated

2
"I can execute the wkhtmltopdf program from the command line" - but can the user that is running the program? If it's not you. Try granting full access to everyone everywhere to the file and try that, it should rule out permission issues.Joel Peltonen
Okay managed to sort it out. Not sure what the problem was though. I uninstalled PDFkit from site-packages and removed all enviro paths to it. Then downloaded a version and copied it to my project folder as before and it worked.Shillz
Cool! You can add that as an answer to this question to help future answer seekers :)Joel Peltonen
Oh hey the solution didn't work for me. I'm on Windows 7, running python 3 from anaconda. It seems like it might be a windows environment variable issue because after fiddling with this solution I get different errors with the filepath to the executable.Jomtung

2 Answers

5
votes

I have spent some time ti figure out the process to converting html pages to pdf on mac os. Here are the steps,

  1. install pdfkit from pip pip install pdfkit
  2. download and install wkhtmltopdf from link
  3. Then setup is done, My python file is

    import pdfkit
    config = pdfkit.configuration(wkhtmltopdf="path_to_exe")
    pdfkit.from_url('http://google.com', 'out.pdf',configuration = config)
    pdfkit.from_file('test.html', 'out.pdf',configuration = config)
    pdfkit.from_string('Hello!', 'out.pdf',configuration = config)
    

And it worked perfectly.

1
votes

Okay managed to sort it out. Not sure what the problem was though. I uninstalled PDFkit from site-packages and removed all enviro paths to it. Then downloaded a version and copied it to my project folder as before and it worked. – Shillz