Class: RailsDataPdf

Inherits:
Prawn::Document
  • Object
show all
Defined in:
app/pdfs/rails_data_pdf.rb

Instance Method Summary collapse

Constructor Details

#initializeRailsDataPdf

Returns a new instance of RailsDataPdf.



6
7
8
9
10
11
# File 'app/pdfs/rails_data_pdf.rb', line 6

def initialize
  default_config = {
    page_size: 'A4'
  }
  super(default_config)
end

Instance Method Details

#empty?Boolean

todo hack for a bug, need confirm ?

Returns:

  • (Boolean)


28
29
30
# File 'app/pdfs/rails_data_pdf.rb', line 28

def empty?
  page.content.stream.length <= 2
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/pdfs/rails_data_pdf.rb', line 13

def run
  return self unless self.empty?

  once_header beginning_data if beginning_data
  repeat_header header_data if header_data
  table_data.each_with_index do |value, index|
    start_new_page unless index == 0
    custom_table value
  end
  once_footer ending_data if ending_data
  repeat_footer footer_data if footer_data
  self
end