I has solucionated my problem:
viewPDF:
public static ResponseEntity<byte[]> viewPdf(String path, String file) {
Path path2 = Paths.get(path);
byte[] contents = null;
try {
contents = Files.readAllBytes(path2);
} catch (IOException e) {
e.getMessage();
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/pdf"));
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
// Download PDF
// headers.setContentDispositionFormData(pathForm.getFile(),
// pathForm.getFile());
// View PDF
headers.add("content-disposition", "inline;filename=" + file);
ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(contents, headers, HttpStatus.OK);
return response;
}
Post:
@RequestMapping(value = "feeMemberList/payMemberList", method = RequestMethod.POST, params = { "createPdf" })
public ResponseEntity<byte[]> createPdf(@Valid @ModelAttribute PathForm pathForm,
Errors errors, @RequestParam("createPdf") String createPdf, RedirectAttributes ra,
Model model) {
String title;
String path = pathForm.getPath() + "/" + pathForm.getFile() + ".pdf";
createPdfFeeMember(messageSource, feeMember.getId(), path, title, createPdf);
return CreatePdf.viewPdf(path, pathForm.getFile());
}
In this way the pdf and keep you open.
The user will appear where you want to save.