0

I'm trying to generate a PDF following the instructions given in http://railscasts.com/episodes/153-pdfs-with-prawn-revised

I'm able to put a background image on a specific page by doing this:

image "#{Rails.root.to_s}/public/document_assets/1_cover.png", :at => [bounds.left - 30, bounds.top + 50], :fit => [@width, @height]

I also got an image to render on the background of multiple pages at once using:

repeat(2..3) { canvas { image("#{Rails.root.to_s}/public/document_assets/1_bg.png", :at => bounds.top_left, :fit => [@width, @height]) } }

but that renders the image on top of everything else on the page, so no text or other content is visible.

I can't seem to figure out how to set the background image property as described in the Prawn documentation. Does anyone know how to do this?

Thanks!

4

1 回答 1

0

我解决了这个问题。您可以在 Railscast 示例中设置边距的 PDF 类中设置背景选项。我的问题是我使用的图像尺寸不正确。当我将其调整为 8.5x11 英寸和每英寸 72 像素时,它起作用了。

于 2013-06-11T16:52:43.327 回答