andriy
andriy

Reputation: 4164

JasperReport how to edit generated report HTML?

Is it possible to edit HTML of generated report on servlet after exporting it with JRHtmlExporter? I just want to change generated report <body> tag to <body onload="window.print()">. All I want is that printer can be choosed by user and not programmatically. Thanks.

Upvotes: 3

Views: 1423

Answers (1)

mdahlman
mdahlman

Reputation: 9390

Typically you are using the JRHtmlExporter in code like this:

JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "build/reports/BatchExportReport.html");
// or maybe this:
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);

In that case you just need to process the generated file, or you need to handle the generated output stream.

But maybe you just need to set JRHtmlExporterParameter.HTML_HEADER. Take a look at that. You could set that to avoid getting this default header as shown in JRHtmlExporter.java:

writer.write("<body text=\"#000000\" link=\"#000000\" alink=\"#000000\" vlink=\"#000000\">\n");

Upvotes: 4

Related Questions