I have this code in the view
prawn_document(:page_size=> "A4", :top_margin => 80, :bottom_margin => 40,
:background => "public/uploads/1.png") do |pdf|
creation_date = Time.now.strftime('%d-%m-%Y')
posts = @posts.each do |post|
pdf.pad(10) do
pdf.text post.title
pdf.text post.text
end
end
pdf.page_count.times do |i|
pdf.go_to_page(i + 1)
pdf.draw_text "Creation Date : " + creation_date, :at => [200, 780]
pdf.draw_text "Page : #{i + 1} / #{pdf.page_count}", :at => [450, -3]
end
end
This gives me the following output:
and this
As you can see in the first image, the image is not centered.
On the 2nd image you can see the image doesn't fit the full page.
I also tried adding the image to each page,the way I added the page number, but here the image overlaps text. But here I can position the image the way I want which works but only that it overlaps the text.
If I put in the header I cannot position and size the image.
So I need help getting the image to fit the page. The image is 700px x 700px.
I also tried using PDFkit, but couldn't get page numbers on that, I feel I am almost there using Prawn, but just this image. Even a different solution will be much appreciated.