A bridge from RubyOnRails to Jasper.
Java (JDK) - www.oracle.com/technetwork/java/javase/downloads/index.html
In Gemfile:
gem 'jasper-bridge'
Run ‘bundle install’.
1.In controller class:
require 'jasper-bridge' class ProductsController < ApplicationController include Jasper::Bridge ... end
2.Put jasper file in “#{Rails.root}/reports” directory.
3.In action of the controller, call method ‘send_doc’ to response the report. Like the example:
def index @products = Product.all send_doc(@products.to_xml, '/products/product', 'Products.jasper', "Products", params[:output_type]) end
The parameters in order of ‘send_doc’ are:
content of XML Xpath of XML node used name of the jasper file name used for file save (without extesion) extension string of filetype returned ('pdf', 'csv', 'rtf', 'html'). Types differents of pdf are not tested.
The java libs on this gem is from JasperReports 3.7.6. So reports must be compiled in the same version.
Copyright © 2011 paulopessoa. See LICENSE.txt for further details.