Skip to content

Commit cf1bba8

Browse files
authored
Merge pull request #820 from bcgov/feature/GRAD2-3666
increase logging for jaspersoft render debugging
2 parents c4022f2 + afabbb3 commit cf1bba8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

api/src/main/java/ca/bc/gov/educ/grad/report/dto/reports/jasper/impl/JasperReportImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.IOException;
3838
import java.io.InputStream;
3939
import java.net.URL;
40+
import java.nio.charset.StandardCharsets;
4041
import java.util.ArrayList;
4142
import java.util.Arrays;
4243
import java.util.LinkedHashSet;
@@ -125,7 +126,14 @@ public ReportDocument export() throws IOException {
125126
case XML:
126127
exporter.setConfiguration(createXmlExporterConfiguration());
127128
exporter.setReportContext(createXmlReportContext());
129+
exporter.setExporterOutput(
130+
new SimpleOutputStreamExporterOutput(out));
131+
break;
128132
case PDF:
133+
exporter.setConfiguration(createPdfExporterConfiguration());
134+
exporter.setExporterOutput(
135+
new SimpleOutputStreamExporterOutput(out));
136+
break;
129137
default:
130138
exporter.setExporterOutput(
131139
new SimpleOutputStreamExporterOutput(out));
@@ -136,6 +144,9 @@ public ReportDocument export() throws IOException {
136144
exporter.setExporterInput(exporterInput);
137145
exporter.exportReport();
138146
bytes = out.toByteArray();
147+
if (ReportFormat.PDF.equals(format)) {
148+
logPdfActualTextDiagnostic(bytes);
149+
}
139150
} catch (final Exception ex) {
140151
final String msg = "Could not export report";
141152
LOG.log(Level.SEVERE, msg, ex);
@@ -401,6 +412,17 @@ private SimpleCsvExporterConfiguration createCsvExporterConfiguration() {
401412
return new SimpleCsvExporterConfiguration();
402413
}
403414

415+
private SimplePdfExporterConfiguration createPdfExporterConfiguration() {
416+
final SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
417+
configuration.setCompressed(false);
418+
return configuration;
419+
}
420+
421+
private void logPdfActualTextDiagnostic(final byte[] bytes) {
422+
final String pdfContent = new String(bytes, StandardCharsets.ISO_8859_1);
423+
LOG.info("PDF ActualText marker present=" + pdfContent.contains("/ActualText"));
424+
}
425+
404426
/**
405427
* Creates a data source outside of the parameter map used in marshaling.
406428
*

0 commit comments

Comments
 (0)