所以我们已经在许多地方工作了没有问题。当地的工作就像一个魅力。但是最后两个地方我们已经部署了我们的应用程序,我们安装了wkhtmltopdf并且无法让wicked_pdf正常工作。
wkhtmltopdf位置:
$ which wkhtmltopdf
=> /usr/local/bin/wkhtmltopdf
我们的wicked_pdf配置:
WickedPdf.config = {
:exe_path => '/usr/local/bin/wkhtmltopdf'
}
错误:
RuntimeError (Failed to execute:
"/usr/local/bin/wkhtmltopdf" -q --footer-html "file:///tmp/wicked_footer_pdf.html20140604-7480-1ag3z4u" --margin-top 20 --margin-bottom 40 --page-size "Letter" --encoding "utf8" --print-media-type - -
Error: PDF could not be generated!):
app/controllers/concerns/downloadable_controller.rb:20:in `block (2 levels) in download'
app/controllers/concerns/downloadable_controller.rb:18:in `download'
我开始认为它的wkhtmltopdf更新版本的b / c或者最后部署的b / c比以前工作正常的更新。但是这些较新的服务器是64位系统而不是以前的服务器的32位。
===编辑===
经过一些进一步的测试后,我发现它的页脚打破了整个事情,但我无法弄清楚原因。
def download
# build resources such as @letter or @study to be used in view
build_resources_for_pdf
respond_to do |format|
format.pdf do
render :pdf => file_name,
:template => "/#{model}/pdf/show.haml",
:encoding => "utf8",
:page_size => "Letter",
:show_as_html => params[:debug].present?,
:print_media_type => true,
:margin => { :bottom => 40, :top => 20 },
:footer => get_footer
end
end
end
def get_footer
{
:html => {
:template => "studies/pdf/pdf_footer",
:locals => {:study => @study}
}
}
end