views:

5

answers:

0

I am generating a PDF report with a basic table, and page header on each page.

Ruport mentions the ability to generate page headers by using top_margin and its extenstion with the all_pages command (ruportbook.com/printable_documents.html in the section labeled Generating Page Headers)

However when I use the example in my existing code, the top_margin seems to be ignored.

class ReportPDF < Ruport::Formatter::PDF
  renders :pdf, :for => [ MemberTableController,
                        MemberPrintViewController]
  build :member_report do
    build_member_report_header

    draw_table(data[0],
        :column_options => {
            :width => 90,
            :heading => { :justification => :center},
            "City/State/Zip\nDischarge Date" => {:justification => :left, :width => 180}
        })
     build_member_report_footer
    render_pdf

  end

and the build member_report_header:

def build_member_report_header
  pdf_writer.top_margin = 30
    all_pages {
    options.text_format = { :font_size => 12, :justification => :left }
  options.page_orientation = :landscape
    move_cursor_to top_boundary
  add_text "#{options.title_str}"
  move_cursor_to top_boundary
  draw_opts = {:x1 => left_boundary, :font_size => 10, :y => top_boundary - 15}
  draw_text "#{options.search_str}", draw_opts         
  move_cursor_to top_boundary
  add_text "#{options.post_name}\nPOST: #{options.post_num}", :justification => :center
  move_cursor_to top_boundary
  draw_opts = {:x1 => right_boundary - 150, :font_size => 10, :y => top_boundary}
  draw_text "DATE: #{Date.today.strftime('%m/%d/%Y')}", draw_opts
  draw_opts = {:x1 => right_boundary - 150, :font_size => 10, :y => top_boundary-15}
  draw_text "TIME: #{Time.now.strftime('%H:%M:%S')}", draw_opts
  draw_opts = {:x1 => right_boundary-50, :font_size => 10, :y => top_boundary}
  draw_text "PAGE:", draw_opts
    }
end

Thanks for the help.