0

我想在 jsp 的小框中查看 pdf 文件,没有任何选项,如下载,view.please 给出 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();
}

and already i done download pdf file use this code 
4

2 回答 2

0

你可以试试这个。我不确定。但你可以试试。

 TINY.box.show({url: "your url", post: "mainid=" + varMainId + "&subid=" + yourID);
于 2013-10-07T11:08:54.863 回答
0

您可以使用PDFObject。这需要Javascript。您也可以使用Object标签如下

<object data="yourfile.pdf" type="application/pdf" width="100%" height="100%">
  <p>Alternative text - include a link <a href="yourfile.pdf">yourfile</a></p>
</object>
于 2013-10-07T11:03:14.727 回答