Skip to content

Commit

Permalink
修复示例bug,修复部分浏览器不能显示bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gjTool committed Mar 6, 2024
1 parent 8a8aafb commit 6de7b60
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 93 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
node_modules
package-lock.json
pdf
index
git
testPDF
example
fonts
version
test
testPDF
.github
.vscode
.github
pdf
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ version
test
testPDF
.github
.vscode
.vscode
pdf
2 changes: 1 addition & 1 deletion example/react-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pdfh5": "^1.4.8",
"pdfh5": "^1.4.9",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
Expand Down
3 changes: 2 additions & 1 deletion example/test/build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {

// these devServer options should be customized in /config/index.js
devServer: {
useLocalIp: true,
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
Expand All @@ -31,7 +32,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
host: '0.0.0.0',
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
Expand Down
12 changes: 8 additions & 4 deletions example/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"author": "gjTool <[email protected]>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 0.0.0.0",
"start": "npm run dev",
"build": "node build/build2.js"
"build": "node build/build.js"
},
"dependencies": {
"axios": "^0.19.2",
"canvas": "^2.11.2",
"dommatrix": "^1.0.3",
"pdfh5": "^1.4.8",
"pdfh5": "^1.4.9",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"web-streams-polyfill": "^3.2.1"
Expand Down Expand Up @@ -72,6 +72,10 @@
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"optionalDependencies": {
"canvas": "^2.11.2",
"path2d-polyfill": "^2.0.1"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
Expand All @@ -81,4 +85,4 @@
"last 2 versions",
"not ie <= 8"
]
}
}
6 changes: 3 additions & 3 deletions example/vite4vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
},
"dependencies": {
"dommatrix": "^1.0.3",
"pdfh5": "^1.4.8",
"pdfh5": "^1.4.9",
"vue": "^3.3.4",
"web-streams-polyfill": "^3.2.1",
"canvas": "^2.11.2",
Expand Down
2 changes: 1 addition & 1 deletion example/vue3demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"core-js": "^3.8.3",
"pdfh5": "^1.4.8",
"pdfh5": "^1.4.9",
"vue": "^3.2.13",
"vuetify": "^3.0.0",
"web-streams-polyfill": "^3.2.1",
Expand Down
8 changes: 4 additions & 4 deletions js/pdf.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/pdf.worker.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/pdfh5.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;
(function (g, fn) {
var version = "1.4.8",
pdfjsVersion = "2.15.349";
var version = "1.4.9",
pdfjsVersion = "2.11.338";
console.log("pdfh5.js v" + version + " && pdf.js v" + pdfjsVersion + " https://pdfh5.gjtool.cn");
if (typeof require !== 'undefined') {
if (g.$ === undefined) {
Expand Down Expand Up @@ -1470,7 +1470,7 @@
if (options.cMapUrl) {
obj.cMapUrl = options.cMapUrl;
} else {
obj.cMapUrl = 'https://unpkg.com/browse/pdfjs-dist@3.8.162/cmaps/';
obj.cMapUrl = 'https://unpkg.com/browse/pdfjs-dist@2.11.338/cmaps/';
}
if (options.httpHeaders) {
obj.httpHeaders = options.httpHeaders;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_from": "pdfh5",
"_id": "[email protected].8",
"_id": "[email protected].9",
"_inBundle": false,
"_integrity": "sha512-9I0AcoEdefvFJZqwv/1Q5ht4QGzmieoVqkd0uehp+62H0KrWtnXYfnHjlwQcfiStdynpCYYJu3A6F1AVUBbqbQ==",
"_location": "/pdfh5",
Expand All @@ -19,7 +19,7 @@
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/pdfh5/-/pdfh5-1.4.8.tgz",
"_resolved": "https://registry.npmjs.org/pdfh5/-/pdfh5-1.4.9.tgz",
"_shasum": "c5e1a233c4baa346727bb968e7a68e2c3453b5aa",
"_spec": "pdfh5",
"_where": "/Users/gaojin/npm-pdfh5",
Expand Down Expand Up @@ -57,5 +57,5 @@
"url": "git+https://github.com/gjTool/pdfh5.git"
},
"scripts": {},
"version": "1.4.8"
"version": "1.4.9"
}
134 changes: 67 additions & 67 deletions pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,73 +93,73 @@
pdfh5.on("complete", function (status, msg, time) {
console.log("状态:" + status + ",总耗时:" + time + "毫秒,总页数:" + this.totalNum, msg);
});
// pdfh5.on("scroll", function (scrollTop, currentNum) {
// console.log("scrollTop:"+scrollTop,"currentNum:"+currentNum);
// });
//配置项参数 renderType:"svg" 渲染模式为svg,默认canvas
// var pdfh5 = new Pdfh5('#demo', {
// pdfurl: "./default.pdf",
// renderType:"svg"
// });

//配置项参数 URIenable:true 开启获取地址栏file参数,获取地址栏pdf路径?file=xxx.pdf,默认false不开启
// var pdfh5 = new Pdfh5('#demo', {
// URIenable:false,
// pdfurl: "./default.pdf"
// });

//配置项参数 是否显示小部件 顶部绿色加载进度条loadingBar 左上角页码显示pageNum 右下角回到顶部按钮backTop 默认显示
// var pdfh5 = new Pdfh5('#demo', {
// loadingBar: false,
// pageNum:false,
// backTop:false
// });

//配置项参数data,文件流形式传入 pdfurl和data二选一
// var pdfh5 = new Pdfh5('#demo', {
// data: data
// });

//配置项参数scrollEnable:false不允许pdf滚动,true允许pdf滚动 默认允许
// var pdfh5 = new Pdfh5('#demo', {
// scrollEnable:false,//是否允许pdf滚动
// pdfurl: url
// });
//pdfh5.scrollEnable(true)允许pdf滚动,pdfh5.scrollEnable(false)不允许pdf滚动

//配置项参数zoomEnable:false不允许pdf手势缩放,true允许pdf手势缩放 默认允许
// var pdfh5 = new Pdfh5('#demo', {
// zoomEnable:false,//是否允许pdf手势缩放
// pdfurl: url
// });

//pdfh5还原、销毁(附带回调函数): pdfh5.reset pdfh5.destroy
//pdfh5显示、隐藏(附带回调函数): pdfh5.show pdfh5.hide

//pdf准备开始渲染,此时可以拿到pdf总页数
// pdfh5.on("ready", function() {
// console.log("pdf准备开始渲染,总页数:" + this.totalNum)
// })

//监听pdf渲染失败
// pdfh5.on("error", function (time) {
// console.log("渲染失败,总耗时" + time + "毫秒")
// })
//监听完成事件,加载失败、渲染成功都会触发
// pdfh5.on("complete", function(status, msg, time) {
// console.log("状态:" + status + ",总耗时:" + time + "毫秒,总页数:" + this.totalNum, msg)
// })

//监听渲染中事件
// pdfh5.on("render", function(currentNum, time, currentPageDom) {
// // currentPageDom.append("<span class='name-logo'>张三</span>")
// console.log("当前页码:" + currentNum)
// })
//on方法,监听事件: 开始初始化 init 准备渲染pdf ready 加载完成 complete 加载失败 error 加载成功 success 渲染pdf中 render
// 缩放zoom 滚动scroll 显示show 隐藏hide 还原reset 销毁destroy 允许缩放zoomEnable 允许滚动scrollEnable

//pdfh5支持在线预览
//http://www.gjtool.cn/pdfh5/pdf.html?file=http://www.gjtool.cn/pdfh5/default.pdf
// pdfh5.on("scroll", function (scrollTop, currentNum) {
// console.log("scrollTop:"+scrollTop,"currentNum:"+currentNum);
// });
//配置项参数 renderType:"svg" 渲染模式为svg,默认canvas
// var pdfh5 = new Pdfh5('#demo', {
// pdfurl: "./default.pdf",
// renderType:"svg"
// });

//配置项参数 URIenable:true 开启获取地址栏file参数,获取地址栏pdf路径?file=xxx.pdf,默认false不开启
// var pdfh5 = new Pdfh5('#demo', {
// URIenable:false,
// pdfurl: "./default.pdf"
// });

//配置项参数 是否显示小部件 顶部绿色加载进度条loadingBar 左上角页码显示pageNum 右下角回到顶部按钮backTop 默认显示
// var pdfh5 = new Pdfh5('#demo', {
// loadingBar: false,
// pageNum:false,
// backTop:false
// });

//配置项参数data,文件流形式传入 pdfurl和data二选一
// var pdfh5 = new Pdfh5('#demo', {
// data: data
// });

//配置项参数scrollEnable:false不允许pdf滚动,true允许pdf滚动 默认允许
// var pdfh5 = new Pdfh5('#demo', {
// scrollEnable:false,//是否允许pdf滚动
// pdfurl: url
// });
//pdfh5.scrollEnable(true)允许pdf滚动,pdfh5.scrollEnable(false)不允许pdf滚动

//配置项参数zoomEnable:false不允许pdf手势缩放,true允许pdf手势缩放 默认允许
// var pdfh5 = new Pdfh5('#demo', {
// zoomEnable:false,//是否允许pdf手势缩放
// pdfurl: url
// });

//pdfh5还原、销毁(附带回调函数): pdfh5.reset pdfh5.destroy
//pdfh5显示、隐藏(附带回调函数): pdfh5.show pdfh5.hide

//pdf准备开始渲染,此时可以拿到pdf总页数
// pdfh5.on("ready", function() {
// console.log("pdf准备开始渲染,总页数:" + this.totalNum)
// })

//监听pdf渲染失败
// pdfh5.on("error", function (time) {
// console.log("渲染失败,总耗时" + time + "毫秒")
// })
//监听完成事件,加载失败、渲染成功都会触发
// pdfh5.on("complete", function(status, msg, time) {
// console.log("状态:" + status + ",总耗时:" + time + "毫秒,总页数:" + this.totalNum, msg)
// })

//监听渲染中事件
// pdfh5.on("render", function(currentNum, time, currentPageDom) {
// // currentPageDom.append("<span class='name-logo'>张三</span>")
// console.log("当前页码:" + currentNum)
// })
//on方法,监听事件: 开始初始化 init 准备渲染pdf ready 加载完成 complete 加载失败 error 加载成功 success 渲染pdf中 render
// 缩放zoom 滚动scroll 显示show 隐藏hide 还原reset 销毁destroy 允许缩放zoomEnable 允许滚动scrollEnable

//pdfh5支持在线预览
//http://www.gjtool.cn/pdfh5/pdf.html?file=http://www.gjtool.cn/pdfh5/default.pdf
</script>
</body>

Expand Down

0 comments on commit 6de7b60

Please sign in to comment.