Reputation: 295
I'm generating a PDF using wicked_pdf
and I want to include a footer with an image in every page.
I generated a file, footer.pdf.erb
, to insert in the bottom of the pages, but, when the PDF is rendered, the image appears at the top and the content of the page disappears.
The versions I'm using are 0.10.2 for wicked_pdf
gem and 0.12.1 for wkhtmltopdf
.
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
Is the :footer
call OK? Or there is another way to insert an image in the footer of the PDFs?
Upvotes: 0
Views: 1767
Reputation: 295
I realized that the problem was the size of the footer, no the configuration. The footer was to high and it reached the top of the page. I solved it adjusting the margin of the bottom. I also changed the footer to footer.html.erb
.
format.pdf do
render :pdf => "pdf",
:margin => {:bottom => 15},
:footer => {:html => {:template => 'layouts/pdfs/footer.html.erb'}}
end
end
Upvotes: 5