Skip to content

Instantly share code, notes, and snippets.

@hidakatsuya
Created August 17, 2011 06:47
Show Gist options
  • Save hidakatsuya/1150960 to your computer and use it in GitHub Desktop.
Save hidakatsuya/1150960 to your computer and use it in GitHub Desktop.
ThinReports Example: Using Events
# coding: utf-8
require 'rubygems'
require 'thinreports'
ThinReports::Report.generate_file('events.pdf') do
use_layout 'events'
events.on :page_create do |e|
e.page.item(:event_page_create).value('Dispatched at before page creating.')
# Set page-number.
e.page.item(:page).value(e.page.no)
end
events.on :generate do |e|
e.pages.each do |page|
page.item(:event_generate).value('Dispatch at before report generating.')
# Set total-page-number.
page.item(:total).value(e.report.page_count)
end
end
3.times { start_new_page }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment