wicked_pdf 错误:无法生成 PDF [英] wicked_pdf Error: PDF could not be generated
问题描述
Gemfile
gem "wicked_pdf"
gem "wkhtmltopdf-binary"
错误:
RuntimeError in CarsController#show
Failed to execute:
/usr/bin/wkhtmltopdf --print-media-type -q - -
Error: PDF could not be generated!
Rails.root: /u/apps/zeepauto/autozeep_update
cars_controller
def show
@class_showcar = true
@class_admin = true
@car = Car.find(params[:id])
@search = Car.search(params[:search])
@cars_see_special = Car.where(:special => "1").order('rand()').limit(3)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @car }
format.pdf do
render :pdf => "#{@car.carname.name}",
:print_media_type => true
end
end
end
show.html.erb
<p class="show_links"><%= link_to url_for(request.params.merge(:format => :pdf)) do %>
<%= image_tag('/images/printversion.png', :alt => 'Download') %>
</p>
wicked_pdf.erb
# config/initializers/wicked_pdf.rb
WickedPdf.config = {
# :exe_path => '/var/lib/gems/1.8/bin/wkhtmltopdf'
:exe_path => '/usr/bin/wkhtmltopdf'
}
推荐答案
我在 gemfile
中已经有了 wkhtmltopdf-binary
,但是因为它在我的本地计算机上运行并且不是在服务器上,我把这个错误留给服务器支持团队来处理..他们已经检查了 wkhtmltopdf 的路径,他们试图将一个简单的 html 转换为 pdf 并且它起作用了..所以他们试图运行一个 bundleupdate
命令,此后 pdf 转换在服务器上也能正常工作.我改变了一个宝石路径,我想这就是问题所在.我发布了我的解决方案,以防其他人也遇到这个问题.
I had wkhtmltopdf-binary
already in gemfile
, but as this was working on my local computer and not on server, I left this error for the server support team to care off.. they have checked the path to wkhtmltopdf, they tried to convert a simple html to pdf and it worked.. so they tried to run a bundle update
command and after this the pdf converting worked fine on server too. I had a gem path changed and I guess this was the problem. I posted my solution in case someone else will have this problem too.
这篇关于wicked_pdf 错误:无法生成 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!