pc端
插件: https://pdfobject.com/
使用:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .pdfobject-container { height: 800px;} .pdfobject { border: 1px solid #666; } </style> </head> <body> <div id="example1"></div> <script type="text/javascript" src="../jquery.min.js"></script> <script type="text/javascript" src="./pdfobject.min.js"></script> <script>PDFObject.embed("./demo.pdf", "#example1");</script> </body> </html>
移动端(兼容pc)
插件:http://mozilla.github.io/pdf.js/
使用
1.点击download
2.将下载下来的文件解压, 将解压之后的文件放到web目录,通过浏览器可以放到viewer.html文件
3.最后出来一个地址,类似http://xxx.com/pdf.js/web/viewer.html?file=http://www.xxx.com/demo.pdf,通过传递file=xxx.pdf,就可以实现在线浏览pdf了,注释pdf的路径必须是完整的访问路径
参考文档:https://www.cnblogs.com/blogxiao/p/8178395.html