One: Display PDF on JSP
<%@ page language= "java" import= "java.util.*,java.io.*" pageencoding= "ISO-8859-1"%><% String path = request.getcontextpath (); String basepath = request.getscheme () + "://" + Request.getservername () + ":" + request.getserverport () + path + "/";%><! doctype html public "-//w3c//dtd html 4.01 transitional//en" >Second: If the visitor's computer is not installed Acrobat Reader, directly with the IFRAME or directly with the link to open, it is not open the document, but directly downloaded, in order to prevent the download, imagine the way media files play, plus some official docs, Consider using the OBJECT tag with the PDF plugin embedded in IE, the results are feasible.
The code is as follows:
<HTML> <HEAD> <META http-equiv= "Content-type" content= "text/html; charset=gb2312" > <meta http-equiv= "Content-style-type" content= "Text/css" > <meta http-equiv= "Content-script-type" content= "Text/javascript" > <title>checking if acrobat reader installed (ie4+) ...</title> <script for= "Window" event= "onload" <!-- document.all [ document.all.PDFNotKnown ? " Ifnoacrobat " : " Ifacrobat " ] .style.display = "Block"; //--></SCRIPT> </HEAD> <BODY> <NOSCRIPT> Cannot determine if you have Acrobat reader (Or the full acrobat) installed <font size= "-1" > (because javascript is unavailable Or turned off) </FONT>. </NOSCRIPT> <div id= "IfnoaCrobat " style=" Display:none "> You need to install Adobe reader to browse files properly, please click here to download adobe reader. </ Div> <object type= "Application/pdf" width=0 height=0 style= "Display:none" > <div id= "Pdfnotknown" style= "Display:none" > </DIV> </object> <div id=showdivstyle= "Z-INDEX: 0; LEFT:10px; WIDTH: 990px; POSITION: absolute; TOP: -8px; HEIGHT: 10px "><object classid=" clsid:ca8a9780-280d-11cf-a24d-444553540000 " width=" 990 " height=" " border=" 0 " top=" -10 " name=" PDF "> <param name=" toolbar " value=" false " ><param name="_version" value= "65539" ><param name= "_extentx" value= "20108" ><param name= "_ Extenty " value=" 10866 "><param name=" _stockprops " value=" 0 "><param name=" SRC " value= "Mxl.pdf" ></object></DIV></BODY></HTML>
Third: In the Web page directly display the file in PDF format for easy reading. But if the file load speed will be very slow, and if the client does not install the PDF reading plug-in, it will not be able to see, but still posted out, picking it. (1.pdf to change to its own PDF file path inserted into the paging file)
HTML code:
<object classid= "CLSID: ca8a9780-280d-11cf-a24d-444553540000 " width=" " height=" 1050 " border=" 0 "> <param name= "_version" value= "65539" > <param name= "_ExtentX" value= "20108" > <param name= "_extenty" value= "10866" > <param name= "_stockprops" value= "0" > <param name= "SRC" Value= "1.pdf" > </object> <object classid= "CLSID: ca8a9780-280d-11cf-a24d-444553540000 " width=" " height=" 1050 " border=" 0 "><param Name= "_version" value= "65539" ><param name= "_extentx" value= "20108" ><param name = "_extenty" value= "10866" ><param name= "_stockprops" value= "0" ><param name= "SRC " value=" 1.pdf "></OBJECT>
In the standard browser:
Java code:
<object data= "1.pdf" type= "application/pdf" width= "height=" > Alt: <a href= "1.pdf" >test.pdf</a > </object> <object data= "1.pdf" type= "application/pdf" width= "height=" > Alt: <a href= "1 . pdf ">test.pdf</a></object>
IE7.0 above version of the browser can be used in the following way, the lower version of IE will display two object areas:
java code:
<object classid= "clsid:ca8a9780-280d-11cf-a24d-444553540000" width= " height=" 1050 " Border= "0" > <param name= "_version" value= "65539" > <param name= "_extentx" value= "20108" > <param name= "_ Extenty " value=" 10866 "> <param name=" _stockprops " value=" 0 "> <param name= "SRC" value= "1.pdf" > <object data= "1.pdf" type= "application/pdf" width= " height=" > alt : <a href= "1.pdf" >test.pdf</a> </object> </object> <object classid= "CLSID: ca8a9780-280d-11cf-a24d-444553540000 " width=" " height=" 1050 " border=" 0 "><param Name= "_version" value= "65539" ><param name="_extentx" value= "20108" ><param name= "_extenty" value= "10866" ><param name= "_ Stockprops " value=" 0 "><param name=" SRC " value=" 1.pdf "><object data=" 1.pdf " type= "Application/pdf" width= " height=" "> alt : <a href" = "1.pdf" >test.pdf</a></object></object>
Processing Method 1 in the low version browser:
Java code:
<!--[if ie]> <object classid=] CLSID: ca8a9780-280d-11cf-a24d-444553540000 " width=" " height=" 1050 " border=" 0 "> <param name= "_version" value= "65539" > <param name= " _extentx " value=" 20108 "> <param name=" _extenty " value=" 10866 "> <param name= "_stockprops" value= "0" > <param name= "SRC" value= "1.pdf" > </object> <! [endif]--> <!--[if ! ie]> <!--> <object data= "1.pdf" type= "Application/pdf" Width= " height=" 1050 "> alt : <a href=" Http://get.adobe.com/cn/reader ' >adobe reader.pdf</a> </object> <!--<! [endif]--> <!--[if ie]> <object classid=] CLSID: ca8a9780-280d-11cf-a24d-444553540000 " width=" " height=" 1050 " border=" 0 "><param Name= "_version" value= "65539" ><param name= "_extentx" value= "20108" ><param name = "_extenty" value= "10866" ><param name= "_stockprops" value= "0" ><param name= "SRC " value=" 1.pdf "> </object><! [endif]--> <!--[if ! ie]> <!--> <object data= "1.pdf" type= "Application/pdf" width= " " height= "1050" > alt : <a href= ' Http://get.adobe.com/cn/reader ' >adobe Reader.pdf</a></object> <!--<! [endif]-->
Handling in the low version Browser 2: Show hidden through CSS control:
html code
/* hides the second object from all versions of ie */ * html object.hiddenObjectForIE { display: none; } /* display the second object only for ie5 mac */ /* ie mac \*//*/ * html object.hiddenObjectForIE { display: inline; } /**/ /* hides the second object from all versions of ie */ * html object.hiddenObjectForIE { display: none; } /* Display the second object only for ie5 mac */ /* ie mac \*//*/ * html object.hiddenobjectforie { display: inline; } /**/ <object classiD= "clsid:ca8a9780-280d-11cf-a24d-444553540000" width= " height=" 1050 " border=" 0 "> <param name= "_version" value= "65539" > <param name= "_extentx" value= "20108" > <param name= "_ Extenty " value=" 10866 "> <param name=" _StockProps " value=" 0 " > <param name= "SRC" value= "1.pdf" > <object data= "1.pdf" type= "application/pdf" width= " height=" " class=" Hiddenobjectforie "> alt : <a href=" 1.pdf ">test.pdf </a> </object> </object>
HTML code
Show pdf| on JSP | Web page directly open PDF method and parameter setting for displaying PDF document in IE