Search code examples
pythondjangopython-2.7wkhtmltopdf

django-wkhtmltopdf gives "[Error 2] The system cannot find the file specified"?


urls.py

from wkhtmltopdf.views import PDFTemplateView
url(r'^pdf/$', PDFTemplateView.as_view(template_name='base/template.html',
            filename='template.pdf', 
            header_template='base/header.html', 
            footer_template='base/header.html', 
            ), name='pdf')

cmd is configured in my settings.py file as shown below

WKHTMLTOPDF_CMD = "C:\Python27\Lib\site-packages\wkhtmltopdf"

I still get the same error

solved

This issue was solved by replacing forward slashes with backward slashes in path as shown below

WKHTMLTOPDF_CMD = "C:/Python27/Lib/site-packages/wkhtmltopdf"

Now i get a new error "[Error 5] Access is denied"


Solution

  • the WKHTMLTOPDF_CMD should point to the wkhtmlpdf.exe binary which is a separate install from the wkhtmltopdf python package.

    download the binary at their website