lib/jasper-command-line/jasper.rb in jasper-command-line-0.3.4 vs lib/jasper-command-line/jasper.rb in jasper-command-line-0.3.5

- old
+ new

@@ -30,10 +30,11 @@ options ||= {} parameters ||= {} jrxml_file = jasper_file.sub(/\.jasper$/, ".jrxml") sign_options = options.delete(:signature) + locale_options = options.delete(:locale) # begin # Convert the ruby parameters' hash to a java HashMap. # Pay attention that, for now, all parameters are converted to string! jasper_params = @hashMap.new @@ -56,10 +57,12 @@ @jRXmlUtils._invoke('parse', 'Lorg.xml.sax.InputSource;', input_source) end jasper_params.put(@jRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, data_document) + jasper_params.put(@jRParameter.REPORT_LOCALE, @locale.new(locale_options[:language], locale_options[:sub_language])) if locale_options + temp_file = Tempfile.new(['pdf-', '.pdf']) file = temp_file.path temp_file.close! created_files = [file] @@ -77,10 +80,11 @@ jasper_params.put @javaString.new('copy_number'), @javaString.new(copy.to_s) jasper_print = @jasperFillManager.fillReport(jasper_file, jasper_params) File.open(copy_file, 'wb') { |f| f.write @jasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', jasper_print) } + # @jasperExportManager._invoke('exportReportToHtmlFile', 'Lnet.sf.jasperreports.engine.JasperPrint;Ljava.lang.String;', jasper_print, @javaString.new('./x.html')) merge_pdf_command_line << " #{copy_file}" created_files << copy_file end @@ -149,14 +153,16 @@ @jasperCompileManager = Rjb::import 'net.sf.jasperreports.engine.JasperCompileManager' @jasperExportManager = Rjb::import 'net.sf.jasperreports.engine.JasperExportManager' @jasperFillManager = Rjb::import 'net.sf.jasperreports.engine.JasperFillManager' @jasperPrint = Rjb::import 'net.sf.jasperreports.engine.JasperPrint' @jRXmlUtils = Rjb::import 'net.sf.jasperreports.engine.util.JRXmlUtils' + @jRParameter = Rjb::import 'net.sf.jasperreports.engine.JRParameter' # This is here to avoid the "already initialized constant QUERY_EXECUTER_FACTORY_PREFIX" warnings. @jRXPathQueryExecuterFactory = silence_warnings{Rjb::import 'net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory'} @inputSource = Rjb::import 'org.xml.sax.InputSource' @stringReader = Rjb::import 'java.io.StringReader' @hashMap = Rjb::import 'java.util.HashMap' + @locale = Rjb::import 'java.util.Locale' @byteArrayInputStream = Rjb::import 'java.io.ByteArrayInputStream' @javaString = Rjb::import 'java.lang.String' @jFreeChart = Rjb::import 'org.jfree.chart.JFreeChart' end end \ No newline at end of file