diff --git a/pyreportjasper/pyreportjasper.py b/pyreportjasper/pyreportjasper.py index 677e059..e993ffc 100644 --- a/pyreportjasper/pyreportjasper.py +++ b/pyreportjasper/pyreportjasper.py @@ -125,7 +125,7 @@ def instantiate_report(self): report.fill() return report - def process_report(self): + def process_report(self, html_configurations=None): error = None base_input = os.path.splitext(self.config.input) if base_input[-1] == ".jrxml": @@ -139,7 +139,7 @@ def process_report(self): try: formats_functions = { 'pdf': report.export_pdf, - 'html': report.export_html, + 'html': lambda: report.export_html(html_configurations), 'rtf': report.export_rtf, 'docx': report.export_docx, 'odt': report.export_odt, diff --git a/pyreportjasper/report.py b/pyreportjasper/report.py index 89138fd..700c0d8 100644 --- a/pyreportjasper/report.py +++ b/pyreportjasper/report.py @@ -80,6 +80,7 @@ def __init__(self, config: Config, input_file): self.SimpleXlsxReportConfiguration = jpype.JPackage('net').sf.jasperreports.export.SimpleXlsxReportConfiguration self.JRCsvExporter = jpype.JPackage('net').sf.jasperreports.engine.export.JRCsvExporter self.SimpleCsvExporterConfiguration = jpype.JPackage('net').sf.jasperreports.export.SimpleCsvExporterConfiguration + self.SimpleHtmlExporterConfiguration = jpype.JPackage('net').sf.jasperreports.export.SimpleHtmlExporterConfiguration self.JRCsvMetadataExporter = jpype.JPackage('net').sf.jasperreports.engine.export.JRCsvMetadataExporter self.SimpleCsvMetadataExporterConfiguration = jpype.JPackage('net').sf.jasperreports.export.SimpleCsvMetadataExporterConfiguration self.JRSaver = jpype.JPackage('net').sf.jasperreports.engine.util.JRSaver @@ -277,11 +278,14 @@ def export_pdf(self): output_stream_pdf.flush() # if no buffer used, it can be ignored. output_stream_pdf.close() - def export_html(self): + def export_html(self,html_configurations=None): exporter = self.HtmlExporter() exporter.setExporterInput(self.SimpleExporterInput(self.jasper_print)) output_stream = self.SimpleHtmlExporterOutput(self.get_output_stream(".html")) exporter.setExporterOutput(output_stream) + configuration = self.SimpleHtmlExporterConfiguration() + configuration.setHtmlHeader(html_configurations) + exporter.setConfiguration(configuration) exporter.exportReport() def export_rtf(self):