Open a PDF file in the Web

Source: Internet
Author: User
Tags pdfobject

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.