Sha256: d426566333f3ee869186e5c5e456e20bd2c7172b33a321a3a81f376a70a68cfb
Contents?: true
Size: 983 Bytes
Versions: 41
Compression:
Stored size: 983 Bytes
Contents
# encoding : utf-8 class PdfReport < Prawn::Document def to_pdf(model, mode_scope) columns = model.attribute_names data = [columns] mode_scope.each{ |modelobj| data << (columns.map{ |c| modelobj[c].to_s }).to_a } table data, :header => true, :cell_style => { :padding => 5 } do i = 0 for col in columns align = case model.columns_hash[col].type when "integer" then 'right' when "string", "text" then 'left' else 'center' end style(columns(i)){ |c| c.align = align.to_sym } i += 1 end end # Paginate font_size 10 number_pages Time.now.strftime('%d/%m/%Y - %H:%M') + ' - <page>/<total>', :at => [0, -5], :align => :center repeat(:all) do bounding_box([0,0], :width => 540, :height => 2) do stroke_horizontal_rule end end render end end
Version data entries
41 entries across 41 versions & 1 rubygems