I want to preview a pdf file genereted with java, but the following code gives this error
Unrecognized response type; displaying content as text.
@GetMapping("/previewPDF/{codeStudent}")
public ResponseEntity<byte[]> previewPDF(@PathVariable("codeStudent") String code) throws IOException {
byte[] pdf = //pdf content in bytes
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "inline; filename=" + "example.pdf");
headers.setContentType(MediaType.parseMediaType("application/pdf"));
return ResponseEntity.ok().headers(headers).body(pdf);
}
