My code is not downloading the pdf unless i install internet download manager
function downloadPdfDocument(bytes){
$.post("/pdf/" + bytes ).done(function (data) {
}).fail(function() {
$("#cd-errors").show();
$("#cd-errors").html("PDF file could not be downloaded");
});
}
@PostMapping("/pdf/{policyNumber}")
public ResponseEntity<byte[]> downloadPdf( @PathVariable("policyNumber") String policyNumber) throws IOException, JRException {
//code to prepare parameters
byte[] contents = jasperUtils.generateStatement(null, null, null, transactionHistories, statementInformations);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/pdf"));
headers.add("content-disposition", "inline;filename=" + policyNumber + ".pdf");
headers.setContentDispositionFormData(policyNumber + ".pdf", policyNumber + ".pdf");
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(contents, headers, HttpStatus.OK);
return response;
}