1

I am using Grails 2.1.1. I am designing report in i-report and to generate it I am using jasper plugin 1.10.0. When I am generating a PDF report it is showing with Adobe Reader but I want to write it in browser. I don't want to use Jasper controller only Jasper service.

Here are my attempts below so far I've understood.

My report generate action

def reportDef = new JasperReportDef(name: jasperName, parameters: parameters, fileFormat: JasperExportFormat.PDF_FORMAT)
response.reset();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline; filename=\"" + fileName + ".pdf\"");
response.outputStream << jasperService.generateReport(reportDef).toByteArray()
response.outputStream.flush()
return;
Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
Sumon Bappi
  • 1,937
  • 8
  • 38
  • 82

1 Answers1

0

I think it is all due to content type. You have used response.setContentType("application/pdf");

Instead of this, you can use
response.setContentType("application/octet-stream");

Ramsharan
  • 2,054
  • 2
  • 22
  • 26