-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a manual entry for alternate page numbers
It was unclear how to do this, and I had submitted a previous pull request that did not explore the existing API. After a bit of work, this was the method that I ended up using. I wanted to make sure that the manual (which is very helpful) was updated.
- Loading branch information
1 parent
e65c244
commit 6848965
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# encoding: utf-8 | ||
# | ||
# Below is the code to generate page numbers that alternate being rendered | ||
# on the right and left side of the page. The first page will have a "1" in | ||
# the bottom right corner. The second page will have a "2" in the bottom | ||
# left corner of the page. The third a "3" in the bottom right, etc. | ||
require File.expand_path(File.join(File.dirname(__FILE__), | ||
%w[.. example_helper])) | ||
|
||
filename = File.basename(__FILE__).gsub('.rb', '.pdf') | ||
Prawn::ManualBuilder::Example.generate(filename) do | ||
text "This is the first page!" | ||
|
||
10.times do | ||
start_new_page | ||
text "Here comes yet another page." | ||
end | ||
|
||
string = "<page>" | ||
odd_options = { :at => [bounds.right - 150, 0], | ||
:width => 150, | ||
:align => :right, | ||
:page_filter => :odd, | ||
:start_count_at => 1 } | ||
even_options = { :at => [0, bounds.left], | ||
:width => 150, | ||
:align => :left, | ||
:page_filter => :even, | ||
:start_count_at => 2 } | ||
number_pages string, odd_options | ||
number_pages string, even_options | ||
end |
This file contains 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