I'm using Jasperreports, version 5.5.2, with Java version 1.6.0_38.
When I export a report to HTML, I obtain a file with this default template:
<html>
<head>
<title></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style type="text/css">
a {text-decoration: none}
</style>
</head>
<body vlink="#000000" text="#000000" link="#000000" alink="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="50%"> </td>
<td align="center">
<!-- The report -->
</td>
<td width="50%"> </td>
</tr>
</tbody>
</table>
</body>
</html>
So with this template, my report is shown at the center of the page. But I'd like to align the report to the left.
I've found one solution: using the parameter HTML_HEADER of the JRHtmlExporter... but the classes have been deprecated (http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHtmlExporter.html). So sadly I'm not able to use it. This was the solution:
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,
"<html>"+
"<head>"+
" <title></title>"+
" <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>"+
" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/jasper.css\" />"+
" <style type="text/css">"+
" a {text-decoration: none}"+
" </style>"+
"</head>"+
"<body text="#000000" link="#000000" alink="#000000" vlink="#000000">"+
"<table width="100%" cellpadding="0" cellspacing="0" border="0">"+
"<tr><td width="50%"> </td><td align="center">");
exporter.exportReport();
Now I have to use the net.sf.jasperreports.export.HtmlExporter and net.sf.jasperreports.export.SimpleHtmlReportConfiguration classes, in this way:
HtmlExporter exporterHTML = new HtmlExporter();
SimpleExporterInput exporterInput = new SimpleExporterInput(report.getJasperPrint());
exporterHTML.setExporterInput(exporterInput);
HtmlExporterOutput exporterOutput = new SimpleHtmlExporterOutput(out);
exporterHTML.setExporterOutput(exporterOutput );
SimpleHtmlReportConfiguration reportExportConfiguration = new SimpleHtmlReportConfiguration();
reportExportConfiguration.setWhitePageBackground(false);
reportExportConfiguration.setRemoveEmptySpaceBetweenRows(true);
exporterHTML.setConfiguration(reportExportConfiguration);
exporterHTML.exportReport();
But I'm not able to fix my problem in any way.
Can anyone help me? Thank you.