【问题标题】:Insert image in PDF footer with wicked_pdf使用 wicked_pdf 在 PDF 页脚中插入图像
【发布时间】:2014-08-25 18:14:37
【问题描述】:

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

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

我使用的版本是 wicked_pdf gem 的 0.10.2 和 wkhtmltopdf 的 0.12.1。

footer.pdf.erb

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

controller.rb

format.pdf do
  render  :pdf => "pdf",
          :footer => {:html => {:layout => 'layouts/pdfs/footer.pdf.erb'}}
end

:footer 通话可以吗?或者还有其他方法可以在 PDF 的页脚中插入图像?

【问题讨论】:

    标签: image footer wkhtmltopdf wicked-pdf


    【解决方案1】:

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

    format.pdf do
      render  :pdf => "pdf",
              :margin => {:bottom => 15},
              :footer => {:html => {:template => 'layouts/pdfs/footer.html.erb'}}
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 1970-01-01
      • 1970-01-01
      • 2014-05-07
      相关资源
      最近更新 更多