使用HttpServletResponse进行流式处理后显示Print Dialog

时间:2015-10-08 09:39:00

标签: java jsf

我想知道是否有办法在流式传输或使用HttpServletResponse写入输出流后显示浏览器的打印对话框,如下面的代码段所示:

HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        response.reset();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "attachment; filename=\"testFile.pdf\"");

        OutputStream output = response.getOutputStream();
        output.write(finalData);
        output.flush();
        output.close();

0 个答案:

没有答案