2014-07-04 34 views
0

我使用wicked_pdf生成PDF,我想在每個頁面中包含一個包含圖像的頁腳。用wicked_pdf插入圖像在PDF頁腳中

我生成了一個文件footer.pdf.erb,插入到頁面的底部,但是當呈現PDF時,圖像出現在頂部,頁面內容消失。

我使用的版本爲wicked_pdf寶石爲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呼叫OK?或者有另一種方法在PDF的頁腳插入圖像?

回答

3

我意識到問題是頁腳的大小,沒有配置。頁腳高到了頁面的頂部。我解決了它調整底部的邊緣。我也將頁腳更改爲footer.html.erb

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