是什么 ? | : | a PDF viewer with HTML5 |
开发语言 | : | CSS、JavaScript |
官方主页 | : | https://mozilla.github.io/pdf.js |
源码仓库 | : | https://github.com/mozilla/pdf.js |
BootCDN⤵︎
<script src="https://cdn.bootcdn.net/ajax/libs/pdf.js/2.4.456/pdf.min.js"></script>
step1、通过包管理器
安装pdf.js
包管理器 | 安装命令 |
---|---|
bower | bower install pdfjs --save |
npm | npm install pdfjs --save |
yarn | yarn add pdfjs |
step2、进入pdfjs
目录,并查看它的内容
.
├── AUTHORS
├── LICENSE
├── README.md
├── docs
├── examples
├── extensions
├── external
├── gulpfile.js
├── l10n
├── make.js
├── package.json
├── pdfjs.config
├── src
├── test
└── web
下载下来的只是源代码,我们需要对文件进行合并压缩处理。
step3、通过npm安装该项目的所有依赖
npm install
step4、通过gulp进行构建
gulp dist
构建后,生成了build/dist/build/pdf.min.js
文件。
如果你想支持IE浏览器,你还需要引入build/dist/build/lib/shared/compatibility.js
,他对兼容性问题做了处理。
<script src="/bower_components/pdfjs/build/dist/build/pdf.min.js"></script>
<script src="/bower_components/pdfjs/build/dist/build/lib/shared/compatibility.js"></script>