django-wkhtmltopdf icon indicating copy to clipboard operation
django-wkhtmltopdf copied to clipboard

returned non-zero exit status 1

Open durdenk opened this issue 7 years ago • 5 comments

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

durdenk avatar Aug 16 '17 19:08 durdenk

I had the same problem. Try to add this to your settings.py file:

WKHTMLTOPDF_CMD = 'xvfb-run -a wkhtmltopdf'

eduardocasas avatar Nov 22 '17 10:11 eduardocasas

Could you put the code of your template? I solve my problem eliminating my style-sheets loaded from static

eersya avatar Aug 02 '18 17:08 eersya

@eduardocasas answer solved the problem for me.

jlariza avatar Aug 03 '18 16:08 jlariza

xvfb-run -a wkhtmltopdf

if I add this to settings.py i get another error :

No such file or directory: 'xvfb-run'

sharadm20 avatar Feb 06 '20 13:02 sharadm20

@sharadm20

apt-get update && apt-get install -y xvfb

Goldziher avatar Mar 04 '21 12:03 Goldziher