Question

I've got pdf file and I want to add an image on it. There are two pages in my pdf file and I want to add image on every page.

Prawn::Document.generate("img/full_template.pdf", :template => "img/template.pdf") do |pdf|
  avatar = "img/crop_after.png"
  pdf.image avatar, :at => [100,10], :scale => 0.4
  pdf.image avatar, :at => [300,30], :scale => 0.4
end

When I run this code I got four avatar images on first pdf page (two in full size and two scaled and in position I want). Can anyone tell me, how can I add first image to the first pdf page and second image to second pdf page?

Was it helpful?

Solution

Try using start_new_page between the images.

That way your second image will be placed on a new page.

EDIT: If your template already has multiple pages you can use go_to_page to navigate between the pages

http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Document.html#method-i-go_to_page

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top