Amigos,
estou tentando mostrar um documento pdf no browser com o seguinte código:
byte[] arquivo = null;
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse) context.getResponse();
try {
File f = new File("c:\\temp\\anexo.pdf");
arquivo = fileToByte(f);
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline;filename=c:\\temp\\arquivo.pdf");
response.setContentLength(arquivo.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(arquivo);
ouputStream.flush();
ouputStream.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("Erro ao abrir arquivo: " + e.getMessage());
}
Só que em vez de mostrar o arquivo, é mostrado a seguinte string no browser:
%PDF-1.4 %äüöß 2 0 obj <> stream x��K���ׯ���������r�dvѳ������������?o�뎎^ =�?w���{낃S����N���7 dű��O�����b�ob��=�_0 �y�N)�*��6�������?���j���}>��A���y��j]S�v� �#��ʾOT�g� Fj�� nw�ݟ��K V�f%c7ӠqF�:y�� ���I�06�?�(�e�ؒ�ee V�I���є%1��M���’� ���z|����7?� {:1���p����풊��m��`h��C���-�4�jSw��������9������N��BW�1r���]O��������=�# <����Kϣ/M�N�H�����s[D���Oi
Alguém tem idéia do que pode ser isso?

