Abrir archivo PDF con JAVA
Publicado por Jorge Briones (1 intervención) el 27/12/2020 23:51:59
Buenas tardes, tengo el siguiente problema. He creado un archivo PDF mediante JAVA, el cual lo tengo en un array de bytes. El tema es que quiero que al ejecutar mi servicio se abra el PDF, no que se descargue y no se como hacerlo, lo que tengo hasta el momento y lo descarga es lo siguiente:
Cualquier ayuda les estaria muy agradecido. Saludos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@CrossOrigin(origins = "*")
@GetMapping(value ="/esignature-bizagi/order-pdf-wildcard/{pathFiles},{wildcard}", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> getWildcardA350(@PathVariable String pathFiles, @PathVariable String wildcard {
byte[] pdf = corBlobDataService.getWildcardA350(pathFiles, wildcard);
ByteArrayResource resource = new ByteArrayResource(pdf);
HttpHeaders header = new HttpHeaders();
header.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=wildcard.pdf");
header.add("Cache-Control", "no-cache, no-store, must-revalidate");
header.add("Pragma", "no-cache");
header.add("Expires", "0");
if (null != pdf && pdf.length >0) {
return ResponseEntity.ok()
.headers(header)
.contentLength(pdf.length)
.contentType(MediaType.APPLICATION_PDF)
.body(resource);
} else {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
Cualquier ayuda les estaria muy agradecido. Saludos.
Valora esta pregunta
0