First Quote JS file
1. <script type= "Text/javascript" src= "Js/pdfobject.min.js" ></script>
<script type= "Text/javascript" src= "Js/pdfobject.js" ></script>
2. Reference style: (the style is indispensable because the height of the PDF in the page is set here)
<style type= "Text/css" >
. held {
Display:none;
}
. pdfobject-container {
height:900px;
}
. pdfobject {
border:1px solid #666;
}
</style>
3. JS code is as follows:
Note: Here to use the window.onload detailed everyone is not unfamiliar with it. If it's not clear, simply describe it (window.onload is executing a function after the DOM document tree has been loaded and all the files have been loaded. This means that when you finish creating the PDF file and then load all the files, the open PDF function is not performed.
<script type= "Text/javascript" >
Window.onload = function () {
var Pdf = $ ("#lblUrl"). Text (); Note: This is the post-generated PDF address (I used to hide a control to give the address to this control in the get and add to Pdfobject.embed (PDF, "#example1") in jquery; Following
Pdfobject.embed (PDF, "#example1");
};
</script>
4. The open PDF file is displayed in this div. This is a very simple div to take care of. (Note: The ID of this div must be and pdfobject.embed (PDF, "#example1"); This is the same, otherwise there will be problems. )
<body ms_positioning= "GridLayout" >
<form id= "Form1" method= "POST" runat= "Server" >
<div id= "example1" ></div>
</form>
</body>
5. Remember that this must be installed: Acrobat Reader will not be able to open the PDF file in the Web page
6. Question Answer:
If you encounter the following issues:
Tip Error: Pdfobject There is an error on this page. Acrobat may not display the page correctly, please contact the creator of the PDF document
This error is not caused by referencing pdfobject.min.js this JS file. I've been doing this for a long time.
The following is the official address: https://pdfobject.com/
I hope the above is helpful to you. If not, read it as a novel. Ha ha
Open a PDF file in the Web