2013-10-07 60 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);