【问题标题】:how to display pdf file in pop u window in jsp如何在jsp的pop u窗口中显示pdf文件
【发布时间】:2013-10-07 12:06:44
【问题描述】:

我已经完成了我的 pdf 视图,但现在我只想动态查看 pdf 文件弹出窗口而不是下载选项和保存选项,所以请在 java 中给出一些示例 我现在使用此代码

File f= new File(file);
if(f.exists()){
ServletOutputStream op= response.getOutputStream();
response.reset();
if(check==1){
response.setContentType("application/pdf");
}else{
response.setContentType(content);
                    }
// response.setHeader("Content-disposition","attachment;      filename=" +fileName);
byte[] buf = new byte[4096];
int length;
DataInputStream in = new DataInputStream(new FileInputStream(f));
while ((in != null) && ((length = in.read(buf)) != -1)){
op.write(buf,0,length);
            }
in.close();
op.flush();
op.close();
    }  

【问题讨论】:

标签: java jsp


【解决方案1】:

如果不使用 iText 等外部库,这是不可能的。

从浏览器下载或保存 pdf 的能力是 PDF 中存在的属性,浏览器中的 pdf 插件读取并在浏览器中启用该属性。因此,您必须在 PDF 本身中禁用该属性,以便浏览器强制执行该约束。

这是一个示例链接 http://www.coderanch.com/t/329511/java/java/revoke-permission-save-copy-PDF

【讨论】:

    猜你喜欢
    • 2018-10-13
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    • 2013-12-22
    • 1970-01-01
    • 2012-10-29
    • 2013-04-20
    相关资源
    最近更新 更多