Hello everyone,
I’m having a problem exporting my JasperPrint to a simple Word document using the AWDocExporter.
Below is the code im currently using:
private static byte[] docToByteArray(JasperPrint jasperPrint, String reportLocation)
{
AWDocExporter exporter = new AWDocExporter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
{
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, reportLocation);
//Aspose Words Export parameters
exporter.setParameter(AWExporterParameter.PAGE_BREAKS, 0);
exporter.setParameter(AWExporterParameter.RECOGNIZE_FIELDS, true);
exporter.setParameter(AWExporterParameter.EXPORT_LINES, true);
exporter.setParameter(AWExporterParameter.SPACING_FACTOR, 0.1);
exporter.setParameter(AWExporterParameter.PAGE_MARGINS, “60px;60px;50px;10px”);
exporter.setParameter(AWExporterParameter.OVERLAP_RESOLUTION_METHOD, AWExporterParameter. OVERLAP_RESOLUTION_METHOD_PUSH_ITEMS);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
System.out.println("File Location: " + reportLocation);
exporter.exportReport(); // exports to baos
System.out.println(“Exported.”);
return baos.toByteArray();
}
catch (Exception jre)
{
System.out.println("JASPER ERROR: "+ jre.getMessage());
jre.printStackTrace();
return null;
}
Upon running this function the stacktrace simply returns “JASPER ERROR: null” and then all the subsequent calling methods. I’ve tried exporting without any of the AWExporterParameters as well as dropping the byteArrayOutputStream but it seems like the exception is thrown every time at exporter.exportReport() and I can’t figure out why.
Thanks in advance