No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Rails plugin for ThinReports DSL. This plugin can write DSL to View.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.7

Runtime

 Project Readme

ThinreportsRails

ThinreportsRails is constructed by Rails Template Handler ThinReports the PDF.

Build Status

Oldname: thinreports-handler

Supported versions

  • Ruby 2.1.X, 2.2.X, 2.3.X
  • Rails 3.X, 4.X, 5.X, 6.0
  • ThinReports 0.10.0 or later

Installation

Add this line to your application's Gemfile:

gem 'thinreports-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install thinreports-rails

Usage

Example to, Display in the browser.

Controllers

class OrdersController < ApplicationController
  def index
    @orders = Order.all
  end
end

Views

app/views/orders/index.pdf.thinreports

report.start_new_page
report.page.values printed_at: Time.now
@orders.each do |order|
  report.page.list(:list).add_row do |row|
    row.item(:col1).value order.name
    row.item(:col2).value order.num
  end
end

Example to, Download PDF.

class OrdersController < ApplicationController
  def index
    @orders = Order.all
    respond_to do |format|
      format.pdf {
        send_data render_to_string, filename: 'foo.pdf', type: 'application/pdf', disposition: 'attachment'
      }
    end
  end
end

Configuration

Layout file(.tlf) and options.

Example of using the app/views/reports/index.tlf. Write code like this to index.pdf.thinreports.

:layout_options is an option ThinReports::Report::Base#use_layout method.

report.set_layout tlf: 'reports/index', layout_options: { default: true }

generate options.

report.generate_options(security: {
  user_password: 'foo',
  owner_password: 'bar',
  permissions: {
    print_document: false,
    modify_contents: false,
    copy_contents: false
  }
})

Partial

For exsample to use, app/views/orders/_header.pdf.thinreports. title is local variable in _header.pdf.thinreports.

report.partial! 'header', title: title

Author

Contributing

m(__)m, send me pull request.

Copyright

Copyright (c) 2012 Takeshi Shinoda.