PDFKIT does not find wkhtmltopdf

15,074

Solution 1

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.

Solution 2

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

Share:
15,074
Shillz
Author by

Shillz

Updated on June 24, 2022

Comments

  • Shillz
    Shillz about 2 years

    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