Header

27 views
Skip to first unread message

gpob...@acid.cl

unread,
Oct 25, 2016, 2:51:14 PM10/25/16
to Prawn
I have a header for all pages except the first one with this code:

repeat(lambda { |pg| pg != 1 } , dynamic: true) do
#My header layout goes here..
end

Is there any way to know which page I'm working? I want a specific header in some cases.

Alexander Mankuta

unread,
Oct 25, 2016, 3:01:07 PM10/25/16
to Prawn
Your document knows current page. It's accessible on page_number attribute.

Prawn::Document.generate("hello.pdf") do |doc|
  doc.repeat(lambda { |pg| pg != 1 } , dynamic: true) do
if (doc.page_number % 3) == 0
# Draw fancy stuff on every third page.
end
 
end
end


--
Regards,
Alex
Reply all
Reply to author
Forward
0 new messages