django-wkhtmltopdf
django-wkhtmltopdf copied to clipboard
returned non-zero exit status 1
I think its possibly my mistake, this cannot be that wrong,
settings.py
WKHTMLTOPDF_CMD_OPTIONS = {
'quiet': False,
'disable-javascript': True
}
WKHTMLTOPDF_CMD = '/usr/bin/wkhtmltopdf'
Using:
class MyPDF(PDFTemplateView):
filename = '/home/workspace/panda/test.pdf'
template_name = 'pdf-text.html'
cmd_options = {
'margin-top': 3,
}
I get:
**Command '['/usr/bin/wkhtmltopdf', u'--disable-javascript', '--encoding', u'utf8', u'--margin-top', u'3', u'--quiet', u'False', '/tmp/wkhtmltopdfWaFux9.html', '-']' returned non-zero exit status 1**
If I run this python code:
arg = ['/usr/bin/wkhtmltopdf','/tmp/wkhtmltopdfWaFux9.html','/home/workspace/test.pdf']
subprocess.check_output(arg)
I get the correct behaviour, since I got no permission or other errors doing check_output manually, is it possible that, this view calls wkhtmltopdf with wrong order?
Thanks
I had the same problem. Try to add this to your settings.py file:
WKHTMLTOPDF_CMD = 'xvfb-run -a wkhtmltopdf'
Could you put the code of your template? I solve my problem eliminating my style-sheets loaded from static
@eduardocasas answer solved the problem for me.
xvfb-run -a wkhtmltopdf
if I add this to settings.py i get another error :
No such file or directory: 'xvfb-run'
@sharadm20
apt-get update && apt-get install -y xvfb