pdf.js预览pdf文件
2021-08-16 本文已影响0人
浅浅_2d5a
在github中下载pdf.js
git clone git://github.com/mozilla/pdf.js.git
在外层文件夹test中创建index.html 和考进来一个pdf文件
目录结构如下:
![](https://img.haomeiwen.com/i19978726/5bdb3a3836f04483.png)
index.html中页面内容为
<a href="./pdf.js//web/viewer.html?file=/s.pdf">agggg</a>
test中启动本地服务,点击链接,能加载pdf文件
思考
./pdf.js//web/viewer.html?file=/s.pdf
viewer.html为pdf的模板页面,是pdf.js的
/s.pdf是需要预览的psf文件
因为本地pdf所以没有跨域出现。
如果file后面是网址,并且出现跨域,view.js里面进行注释解决跨域