PDF.js是一款基于HTML5创建的PDF阅读器,兼容大部分主流的浏览器,使用起来,也相对简单。步骤以下:html
下载地址:http://mozilla.github.io/pdf....git
建新文件夹,将PDF.js插件文件放入新建的文件夹。github
在HTML文件代码以下:web
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="google" content="notranslate"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>《使用指南》-柠檬课件</title> <script> function openFile () { var url = "pdf.pdf"; window.open("pdfjs/web/viewer.html?file=" + url); } </script> </head> <body> <input type="button" onclick="openFile()" value="打开"> </body> </html>
注意:由于pdf.js须要依赖http,https协议。因此直接浏览index打开报错。搭个服务,或者用idea的浏览就能够了。浏览器