Post-process report HTML

I have a question about reports. When I generate an HTML report, the result opens in my browser. This is good. However, I would like to be able to post-process the generated HTML report in my java code BEFORE it gets displayed or downloaded. Is there a hook to access the generated HTML for post-processing? My editor.init code is shown below.

public void init(Map<String, Object> params) {
        TablePrintFormAction action = new TablePrintFormAction("Visit Report", patientVisitsTable);

Just to clarify a bit… the reason I want to post-process is so I can format some many-to-many references. Specifically, the Visit entity has a many-to-many attribute that I want to output as a comma-delimited list. For example,

Fruit: apple, pear, banana

I don’t know how to format in this way using the reporting module, so I thought I might use reporting to output the rest of the attributes and then add the MTM printouts using my own code.

Is there a better way to do this?

Hi Eric,

I think the best way to format many-to-many reference is using the groovy band in the report. You can format many-to-many attributes in the groovy script.

I’ll look into that. Here’s what I came up with. The plan here would be to insert the MTMs after Cuba has done the rest of the formatting…

public void onReportB(Component source) {

        Map<String,Object> params = new HashMap<>();
        params.put("entity", patientVisitsTable.getSingleSelected());

        LoadContext<Report> lContext = new LoadContext<>(Report.class);
        lContext.setQueryString("select r from report$Report r where like 'Visit Report'");
        List<Report> reports = dataService.loadList(lContext);
        Report report = reports.get(0);

        ReportOutputDocument outDoc = reportGuiManager.getReportResult(report, params, null);

        byte[] byteArr = outDoc.getContent();
        // Plan to insert formatted (comma-delimited list) MTM references into byte stream here
        ExportFormat exportFormat = ReportPrintHelper.getExportFormat(outDoc.getReportOutputType());
        ExportDisplay exportDisplay = AppConfig.createExportDisplay(this);
        String documentName = outDoc.getDocumentName(); ByteArrayDataProvider(byteArr), documentName, exportFormat);