Java - Abrir archivo PDF con JAVA

 
Vista:

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:

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
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Abrir archivo PDF con JAVA

Publicado por Tom (1831 intervenciones) el 28/12/2020 11:05:52
Tu pregunta no tiene mucho sentido.
De cualquier modo, si tienes un servicio que "envía" un fichero pdf .... el usuario de este servicio deberá "descargar" el pdf antes de hacer cualquier cosa con él ¿ no ?.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar