wkhtmltopdf已退出,返回非零代码{0}Django html to pdf

2024-06-16 19:11:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用wkhtmltoppdf将html转换为pdf。 但我有个错误

raise IOError("wkhtmltopdf exited with non-zero code {0}. error:\n{1}".format(exit_code, stderr.decode("utf-8")))
IOError: wkhtmltopdf exited with non-zero code 1. error:
xvfb-run: error: Xvfb failed to start

我的代码是:

^{pr2}$

我不知道我做错了什么。在

我什么都试过了,但还是犯了同样的错误。在


Tags: formatpdfhtml错误withexitcodeerror
2条回答

你有没有安装XVFB?如果不是,您应该通过包管理器安装它,例如apt-get install xvfb。否则通过/tmp/xvfb-错误.log文件,以获取特定的xvfb错误消息。在

wkhtmltopdf是在X图形服务器的帮助下工作的。 如果我们想在服务器上使用它,那么它将成为一个问题,意味着它将无法工作。 为了使它在服务器上工作,我们需要安装一个X服务器(xvfb)。在

sudo apt-get install xvfb

参考号:https://learnbatta.com/blog/django-html-to-pdf-using-pdfkit-and-wkhtmltopdf-5/

相关问题 更多 >