0
@@ -47,7 +47,7 @@ module PDF
0
attr_reader :margin_left, :margin_right, :margin_top, :margin_bottom
0
- attr_reader :page_width, :page_height
0
+ attr_reader :page_width, :page_height
, :page0
# borrowed from PDF::Writer
0
PAGE_SIZES = { # :value {...}:
0
@@ -124,6 +124,10 @@ module PDF
0
default_font("Sans Serif")
0
+ # maintain a count of pages and array of repeating elements to add to each page
0
# move the cursor to the top left of the usable canvas
0
@@ -257,6 +261,7 @@ module PDF
0
# TODO: raise an error if any unrecognised options were supplied
0
# TODO: add padding between border and text
0
# TODO: how do we handle a single word that is too long for the width?
0
+ # TODO: add an option to draw a border with rounded corners
0
options = default_text_options
0
options.merge!({:border => "tblr", :border_width => 1, :border_color => :black, :bgcolor => nil})
0
@@ -354,6 +359,7 @@ module PDF
0
# <tt>:spacing</tt>:: Space between lines in PDF points
0
# TODO: add support for pango markup (see http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup)
0
+ # TODO: add converters from various markup languages to pango markup. (bluecloth, redcloth, markdown, textile, etc)
0
# TODO: add a wrap option so wrapping can be disabled
0
# TODO: raise an error if any unrecognised options were supplied
0
@@ -584,9 +590,45 @@ module PDF
0
@context.move_to(margin_left,margin_top)
0
+ # add the same elements to multiple pages. Useful for adding items like headers, footers and
0
+ # <tt>spec</tt>:: Which pages to add the items to. :all, :odd, :even, etc. NOT IMPLEMENTED YET
0
+ # To add a circle to the middle of every page
0
+ # pdf.add_repeating_element(:all) do
0
+ # pdf.circle(pdf.absolute_x_middle, pdf.absolute_y_middle, 100)
0
+ def add_repeating_element(spec = :all, &block)
0
+ # TODO: implement spec to allow repeating elements to only appear on selected pages
0
+ # TODO: add basic templating variables so things like page numbers can be used
0
+ # add it to the current page
0
+ # store it so we can add it to future pages
0
# move to the next page
0
+ # <tt>pageno</tt>:: If specified, the current page number will be set to that. By default, the page number will just increment.
0
+ def start_new_page(pageno = nil)
0
+ # apply the appropriate repeating elements to the new page
0
+ @repeating.each do |repeat|
0
+ # move the cursor to the top left of our page body
0
@@ -651,6 +693,16 @@ module PDF
0
+ def default_positioning_options
0
+ # TODO: use these defaults in appropriate places
0
+ :width => points_to_right_margin(x),
0
+ :height => points_to_bottom_margin(y)
0
def default_text_options
0
{ :font => @default_font,
0
:font_size => @default_font_size,
Comments
No one has commented yet.