Created
December 9, 2012 19:31
-
-
Save abhishek77in/4246643 to your computer and use it in GitHub Desktop.
Create a PDF Document using Prawn Library with header, footer and page numbering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "prawn" | |
Prawn::Document.generate("report.pdf") do | |
10.times do | |
start_new_page | |
end | |
repeat :all do | |
move_down 50 | |
pad(20) { text "This padded both before and after" } | |
pad(20) { text "This is an awesome page" } | |
# header | |
bounding_box [bounds.left, bounds.top], :width => bounds.width do | |
font "Helvetica" | |
text "Here's My Fancy Header", :align => :center, :size => 25 | |
stroke_horizontal_rule | |
end | |
# footer | |
bounding_box [bounds.left, bounds.bottom + 25], :width => bounds.width do | |
font "Helvetica" | |
stroke_horizontal_rule | |
move_down(5) | |
text "And here's a sexy footer", :size => 16 | |
end | |
end | |
string = "page <page> of <total>" | |
# Green page numbers 1 to 11 | |
options = { :at => [bounds.right - 150, 0], | |
:width => 150, | |
:align => :right, | |
:page_filter => (1..11), | |
:start_count_at => 1, | |
:color => "007700" } | |
number_pages string, options | |
end |
This helped me a lot.
Thanks
Irving R.
Thanks mate, it really helped to me
Thank you, it helped me a lot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very weel