wicked_pdf: (RuntimeError) Error: Failed to execute /.../shared/bundle/ruby/2.1.0/bin/wkhtmltopdf
This is an occasional error i receive, not sure of the cause, because it you come back a few minutes later, the problem disappears.
full message
Error: Failed to execute:
["/var/www/myapp/shared/bundle/ruby/2.1.0/bin/wkhtmltopdf", "-q", "file:///tmp/wicked_pdf20150630-30571-1f9qkcc.html", "/tmp/wicked_pdf_generated_file20150630-30571-hqfxd7.pdf"]
Error: PDF could not be generated!
Command Error: QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::translate: Painter not active
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::setWorldTransform: Painter not active
QPainter::setOpacity: Painter not active
QPainter::setFont: Painter not active
respond_to do |format|
format.html
format.pdf do
render pdf: 'invoice',
layout: 'pdf.html.erb',
show_as_html: params[:debug].present?
end
Does anyone have an idea? or perhaps just a way of trapping the error and redirecting to an error page ( asking to try again in a few minutes, if this is a concurrency issue )
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 16
the installation on my ubuntu server 16.04 of these lines fixed the issue…
“apt-get install openssl build-essential xorg libssl-dev xfonts-75dpi”
thanks to @cesc1989
@unixmonkey Thanks very much for your answer. I’ve checked the issues you mentioned, but none of those is related to my case. Plus, I’ve just installed wkhtmltopdf as you mentioned and followed @cesc1989 scripts. I don’t know why the pdf is rendered without adding the configuration in the initializer in my case.
@cesc1989 Thanks very much for your answer since I just in stall xorg and xfonts-75dpi while the other were already installed. The pdf is rendered now, cool 👍 Anyway, I’ve got a problem rendering unicode character. The Unicode characters become black boxes. I’ve already had “
<meta charset='utf-8' />
” in the header. I cannot figure the problem of that black boxes. You almost solve my problem. Hope you can help me with this last one, thanks!@PirunSeng Are you using Ubuntu 14.04? I’ve installed wkhtmltopdf for both 32 and 64 bit versions using these scripts:
Good luck!
@PirunSeng You can install
wkhtmltopdf
through your package manager, or download a precompiled binary from http://wkhtmltopdf.org/downloads.html, and point to the binary location in an initializer like this:I tried to do a little research into why this is happening for some people, and though I’m not positive this is this specific issue, I have seen reports of the “painter” not being able to draw on the virtual web browser because of the viewport having an ambiguous height or width…as to why it doesn’t happen all the time, I’m not sure.
Here’s a search across the main
wkhtmltopdf
issue tracker.@PirunSeng since I stopped using the
wkhtmltopdf-binary
gem and decided to install the library, haven’t seen this error. I suggest you do it too.