On Sun, Nov 22, 2009 at 00:07, jaambros <
jo...@kiubo.net> wrote:
> Hi all,
> I expected to obtain a diff heading for each student; but ended up
> with the same heading for all (that of the last student).
> It would appear that the header is rendered at the end using the last
> definition for it.
Perhaps I misunderstand, but this works as expected for me:
require "rubygems"
require "prawn"
require "prawn/layout"
LOREM = "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum. "
Prawn::Document.new do
3.times do |i|
header([0, bounds.height + 20]) do
text "Student #{i}", :style => :bold
end
text LOREM*20
stroke_horizontal_rule
start_new_page unless i==2
end
render_file '/tmp/test.pdf'
end
`open /tmp/test.pdf` # OS X