使用 wicked_pdf 在 PDF 页脚中插入图像

itz*_*iki 0 image footer wkhtmltopdf wicked-pdf

我正在使用生成 PDF wicked_pdf,我想在每个页面中包含一个带有图像的页脚。

我生成了一个文件 ,footer.pdf.erb以插入页面底部,但是,当呈现 PDF 时,图像出现在顶部并且页面内容消失。

我使用的版本是 0.10.2 的wicked_pdfgem 和 0.12.1 的wkhtmltopdf.

页脚.pdf.erb

<html>
  <head>
  </head>
  <body>
    <%=wicked_pdf_image_tag('image_path', :width => "97", :height => "25")%>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

控制器文件

format.pdf do
  render  :pdf => "pdf",
          :footer => {:html => {:layout => 'layouts/pdfs/footer.pdf.erb'}}
end
Run Code Online (Sandbox Code Playgroud)

:footer呼叫OK?或者还有另一种方法可以在 PDF 的页脚中插入图像?

itz*_*iki 5

我意识到问题是页脚的大小,而不是配置。页脚太高了,它到达了页面的顶部。我解决了调整底部边距的问题。我也将页脚更改为footer.html.erb.

format.pdf do
  render  :pdf => "pdf",
          :margin => {:bottom => 15},
          :footer => {:html => {:template => 'layouts/pdfs/footer.html.erb'}}
  end
end
Run Code Online (Sandbox Code Playgroud)