JS plug-in mode open PDF file (browser PDF plugin share) _javascript tips

Source: Internet
Author: User
Tags pdfobject

Two options: a direct link to the PDF file as an img file, similar to the <a href= ""/> This form, such links:

Copy Code code as follows:

<frame src= "Address of PDF file" ></frame>


Another: Use JS plugin ha.
The realization of reading a PDF file of JS Plug-ins a lot, such as: Pdf.js: is a technology prototype is mainly used to display PDF documents on the HTML5 platform, without any local technical support; Jspdf: is an open source library that generates PDFs using JavaScript language (IE is not supported);
More simple and easy to use JS plugin: Pdfobject.js, is a JavaScript library used to dynamically embed PDF documents in HTML.
The effect is as follows:

Pdfobject.js has now been upgraded to 1.2 to support IE9.
Pdfobject.js tenet: Sometimes you need a little JavaScript. When I do, try Pdfobject.
To look at the small number of JS code:

Copy Code code as follows:

<script type= "Text/javascript" >
Window.onload = function () {
var success = new Pdfobject ({URL: "Sample.pdf"}). Embed ();
};
</script>

OK, that's fine. Just write the address right.
What if I load a pdf in a div? Reader net, found that the embed () method can have parameters, no parameter refers to the body, there are parameters are specific to a certain position.

Copy Code code as follows:

<script type= "Text/javascript" >
Window.onload = function () {
var success = new Pdfobject ({URL: "Sample.pdf"}). Embed ("div id");
};
</script>

Of course, you can further set parameters, such as how many seconds you want to preview the speed, there are CSS, no CSS, etc.

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.