= ThinReports Generator

{<img src="https://secure.travis-ci.org/thinreports/thinreports-generator.png" />}[http://travis-ci.org/thinreports/thinreports-generator] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/thinreports/thinreports-generator]

{ThinReports}[http://www.thinreports.org/] is Open Source Reporting Solution for Ruby.

* ThinReports Editor (GUI Designer)
* ThinReports Generator (Report Generator for Ruby)

== Generator's features

Editor's features is {here}[http://www.thinreports.org/features/editor/].

=== Easy to generate PDF file

Design the layout using Editor, then embed values to text field in layout. That's it!

=== Simple runtime environments

Ruby, RubyGems, Prawn and Generator.

=== Dynamic

Generator can be dynamically operated ...

* value of TextBlock
* image of ImageBlock
* styles (border, fill, visibility, position, color, font) of shape

=== For Japan

* Japanese OK
* External characters (Gaiji)

== Supported Versions

* Ruby 1.8.7, 1.9.2, 1.9.3
* JRuby 1.6.5+ (Only 1.8mode)

== Install

Add the following line in your Gemfile:  

  gem 'thinreports'

Then bundle:

  $ bundle

Or:

  $ gem install thinreports

== Usage

*Caution:* In order to use the Generator, you must need the layout file(*.tlf) created with {ThinReportsEditor}[http://www.thinreports.org/features/editor/].

=== Basic format

  require 'thinreports'
  
  report = ThinReports::Report.new :layout => 'report.tlf'
  # Page 1
  report.start_new_page do
    item(:title).value('ThinReports')
  end

  # Page 2
  report.start_new_page do |page|
    page.item(:title).value('Pure Ruby')
    page.item(:title).style(:color, 'red')
  end

  report.generate_file('report.pdf')

Or, 

  ThinReports::Report.generate_file('report.pdf', :layout => 'report.tlf') do
    start_new_page
    
    page.item(:title).value('ThinReports')
    
    start_new_page
    
    page.item(:title).value('Pure Ruby').style(:color, '#ff0000')
  end

=== List format

  report = ThinReports::Report.new :layout => 'list.tlf'
  report.start_new_page

  10.times do |n|
    report.page.list(:default).add_row do |row|
      row.item(:no).value(n)
    end
  end

  report.generate_file('list.tlf')

Or, 

  report.page.list(:default) do |list|
    10.times do |n|
      list.add_row :no => n
    end
  end

Since 0.7.5:

  report = ThinReports::Report.new :layout => 'list.tlf'

  10.times do |n|
    report.list.add_row do |row|
      row.item(:no).value(n)
    end
  end

More simply,

  report.list do |list|
    10.times do |n|
      list.add_row :title => n
    end
  end

* +#start_new_page+ can be omitted because it is created new page automatically when +#list+ is called
* id argument of +#list+ can be omitted if is :default

{Learn more}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started].

=== Rails3

* Rails Template handler for ThinReports DSL: {thinreports-rails}[https://github.com/takeshinoda/thinreports-rails]

== For more information

=== Release information

{News}[http://osc.matsukei.net/projects/thinreports/news] /
{Changelog}[http://osc.matsukei.net/projects/thinreports/wiki/Changelog]

=== Documentation

{Getting Started}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started] /
{Examples}[http://osc.matsukei.net/projects/thinreports/wiki/Examples] /
{HowTos}[http://osc.matsukei.net/projects/thinreports/wiki/HowTos]

=== Support

{Open Forum}[http://osc.matsukei.net/projects/thinreports/boards]

== Author

{Matsukei}[http://www.matsukei.co.jp/] Co.,Ltd.

* twitter: {@thinreports_org}[https://twitter.com/thinreports_org]
* email: {thinreports@gmail.com}[mailto:thinreports@gmail.com]

== Contributing

* Pull request
* Feedback from {here}[http://osc.matsukei.net/projects/thinreports/issues/new]

== License

See LICENSE file.