Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit 1 with binary version 0.12.6-1 #179

Open
Goldziher opened this issue Mar 4, 2021 · 4 comments
Open

Exit 1 with binary version 0.12.6-1 #179

Goldziher opened this issue Mar 4, 2021 · 4 comments

Comments

@Goldziher
Copy link

Hi there,

I recently tried switching between version 0.12.5-1 (2018) to 0.12.6-1 (2020) of the binary (using this link to download it: https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb), but this appears to cause an issue with the library:

  File "/usr/local/lib/python3.9/site-packages/wkhtmltopdf/utils.py", line 146, in wkhtmltopdf
    return check_output(ck_args, **ck_kwargs)
  File "/usr/local/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['wkhtmltopdf', '--encoding', 'utf8', '--footer-html', '/tmp/tmpwf34m2lm.html', '--header-html', '/tmp/tmpjhuavkdp.html', '--page-size', 'A4', '--print-media-type', '/tmp/tmpio80hqhf.html', '-']' returned non-zero exit status 1.

It does work with the older version.

@JPolonia
Copy link

Same problem here downgrading to the 0.12.5-1 (2018) worked

@FabianClemenz
Copy link

FabianClemenz commented Dec 9, 2024

@Goldziher i got this issue working with Docker and latest wkhtmltopdf 0.12.6.1-3 - i found that i needed to pass the correct domain, because my docker image tried to access localhost and wasn't able to get the correct static files -> therefor the error.

had some stuff like

 <link rel="stylesheet" type="text/css" href="{{ domain }}{% static 'css/pdf.css' %}">

in my templates

(tested it building the html by hand in the docker shell and trying to directly use wkhtmltopdf binary)

My Setup:

  • python3.12-slim-bookworm
  • wkhtmltopdf 0.12.6.1-3
  • django 5.1.3

@MarcelHaldimann
Copy link

@FabianClemenz

I'm still not sure about your solution. I had already solved the problem with the localhost with a second environment variable. (In Kubernetes there can be problems resolving the hostname to itself.)

Have you tried to start the server not with python manage.py runserver 0.0.0.0:8000 but with: gunicorn wsgi:application -b 0.0.0.0:8000?

With gunicorn I still get the same error. But if I only change the command in entrypoint.sh it works without problems.

exec python manage.py runserver 0.0.0.0:8000
->
exec gunicorn wsgi:application -b 0.0.0.0:8000

But if I try to get the static files into docker with wget this works without problems. So the static files are served correctly by django.

wget localhost:8000/static/some-file.css

It also works if I execute the wkhtmltopdf command via the bash and the export html in the container. (/tmp/wkhtmltopdf{asd}.html)

It is strange.

@FabianClemenz
Copy link

@MarcelHaldimann as mentioned via email -> also with gunicorn and serving staticfiles via whitenoise i get it working with the code in our repository

So i think the error is related to your setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants