pdf.js使用记录

前言

因公司需要word在线预览功能,又不想花钱,所以就想试试用pdf.js可否实现。

首先,安装pdf.js

$ git clone https://github.com/mozilla/pdf.js.git
$ cd pdf.js

第二步:安装gulp自动化构建工具

$ npm install -g gulp-cli

通过下面命令: gulp -v查看 gulp 的版本,如果命令不存在就是没安装成功。

第三步:安装 PDF.js 的所有依赖

$ npm install

第四步:启动本地Web服务

$ gulp server

 成功启动后,访问http://localhost:8888/web/viewer.html

 也可以通过打开右侧查看所有测试 PDF 文件http://localhost:8888/test/pdfs/?frame

参考:

pdf.js官网:http://mozilla.github.io/pdf.js/
pdf.js github:https://github.com/mozilla/pdf.js

gulp官网:https://www.gulpjs.com.cn/

原文地址:https://www.cnblogs.com/myflowers/p/15042854.html