JS plug-in mode open PDF file

Source: Internet
Author: User
Tags pdfobject

Requirements: JSP page to display the PDF file, below gives two kinds of schemes, JS Plug-ins that kind of good AH

two options: a direct link, the PDF file as an img file, similar to <a href= ""/> This form, such links: The code is as follows: <frame src= "PDF file Address" ></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 see the small number of JS code:       Code as follows: <script type= "Text/javascript" >       window.onload = Functi On () {             var success = new Pdfobject ({URL: "Sample.pdf"}). Embed ();      }; </script>     OK, so 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.     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.