2013-10-07 33 views
0

我想出来像下载任何选项,在JSP小框查看PDF文件,view.please给java源例如如何查看PDF文件中的小框在JSP

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 

回答

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> 
0

你可以用这个one.am不知道它。但是你可以尝试尝试。

TINY.box.show({url: "your url", post: "mainid=" + varMainId + "&subid=" + yourID);