下载地址
http://mozilla.github.io/pdf.js/getting_started/#download
点击后会下载,有点慢
打开后我加了两个文件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jk</title> </head> <body> <div style="height: 100vh;margin: 0 auto"> <iframe src="http://localhost:63343/pdfjs-3.4.120-dist/web/viewer.html?file=http://localhost:63343/pdfjs-3.4.120-dist/git.pdf" style="width: 100%;height:100%;border: red"></iframe> </div> <script> </script> </body> </html>
git.pdf是用于测试的pdf文件
可以使用 iframe 嵌入 viewer.html 来局部预览
效果如下
或者直接新窗口访问
http://localhost:63343/pdfjs-3.4.120-dist/web/viewer.html?file=http://localhost:63343/pdfjs-3.4.120-dist/git.pdf