galera, bom dia … Estou tendo esse erro ao tentar exibir o PDF no browser: "getOutputStream() has already been called for this response"
Porém, com o mesmo código se eu abrir usando o Desktop ele funciona …
[code]public void mostraNaTela(List boletos){
try {
//INFORMANDO O TAMPLATE PERSONALIZADO
File tamplatePersonalizado = new File(ClassLoaders.getResource("/BoletoCarne3PorPagina.pdf").getFile());
byte[] pdfAsByte = groupInPagesReturnByte(boletos, "Carne3PorPagina.pdf", tamplatePersonalizado);
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
try {
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=Carne3PorPagina.pdf");
OutputStream outPut = response.getOutputStream();
outPut.write(pdfAsByte);
response.flushBuffer();
FacesContext.getCurrentInstance().getResponseComplete();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
System.err.println("Erro ao Mostrar: "+e.getMessage());
}
}[/code]