Gathering detailed insights and metrics for pdfh5-repair
Gathering detailed insights and metrics for pdfh5-repair
Gathering detailed insights and metrics for pdfh5-repair
Gathering detailed insights and metrics for pdfh5-repair
npm install pdfh5-repair
Typescript
Module System
Node Version
NPM Version
75.9
Supply Chain
99.1
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (64.1%)
CSS (21.73%)
HTML (10.79%)
Vue (3.23%)
TypeScript (0.14%)
Total Downloads
293
Last Day
2
Last Week
2
Last Month
16
Last Year
138
MIT License
1,041 Stars
363 Commits
246 Forks
15 Watchers
4 Branches
4 Contributors
Updated on Jul 04, 2025
Minified
Minified + Gzipped
Latest Version
1.4.2
Package Id
pdfh5-repair@1.4.2
Unpacked Size
1.86 MB
Size
878.79 kB
File Count
16
NPM Version
8.5.5
Node Version
16.15.0
Published on
Apr 27, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
0%
2
Compared to previous week
Last Month
-40.7%
16
Compared to previous month
Last Year
81.6%
138
Compared to previous year
由于精力有限,本插件暂时不会更新了,如果有问题可以到博客留言并留下联系方式,抽空回复
1<link rel="stylesheet" href="css/pdfh5.css" />
1<div id="demo"></div>
1<script src="js/pdf.js" type="text/javascript" charset="utf-8"></script> 2<script src="js/pdf.worker.js" type="text/javascript" charset="utf-8"></script> 3<script src="js/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script> 4<script src="js/pdfh5.js" type="text/javascript" charset="utf-8"></script>
1var pdfh5 = new Pdfh5('#demo', { 2 pdfurl: "./default.pdf" 3});
1npm install pdfh5
1<template> 2 <div id="app"> 3 <div id="demo"></div> 4 </div> 5</template> 6<script> 7 import Pdfh5 from "pdfh5"; 8 export default { 9 name: 'App', 10 data() { 11 return { 12 pdfh5: null 13 }; 14 }, 15 mounted() { 16 //实例化 17 this.pdfh5 = new Pdfh5("#demo", { 18 pdfurl: "../../static/test.pdf" 19 }); 20 //监听完成事件 21 this.pdfh5.on("complete", function (status, msg, time) { 22 console.log("状态:" + status + ",信息:" + msg + ",耗时:" + time + "毫秒,总页数:" + this.totalNum) 23 }) 24 } 25 } 26</script> 27 28<style> 29 @import "pdfh5/css/pdfh5.css"; 30 *{ 31 padding: 0; 32 margin: 0; 33 } 34 html,body,#app { 35 width: 100%; 36 height: 100%; 37 } 38</style>
1 import Pdfh5 from "pdfh5"; 2 import "pdfh5/css/pdfh5.css";
1var pdfh5 = new Pdfh5(selector, options);
参数名称 | 类型 | 取值 | 是否必须 | 作用 |
---|---|---|---|---|
selector | String | - | √ | pdfh5的容器选择器 |
options | Object | - | × | pdfh5的配置项参数 |
1var pdfh5 = new Pdfh5('#demo', { 2 pdfurl: "./default.pdf" 3});
参数名称 | 类型 | 取值 | 作用 |
---|---|---|---|
pdfurl | String | - | pdf地址 |
URIenable | Boolean | true、false, 默认false | true开启地址栏file参数 |
data | Array(arraybuffer) | - | pdf文件流 ,与pdfurl二选一(二进制PDF数据。使用类型化数组(Uint8Array)可以提高内存使用率。如果PDF数据是BASE64编码的,请先使用atob()将其转换为二进制字符串。) |
renderType | String | "canvas"、"svg",默认"canvas" | pdf渲染模式 |
pageNum | Boolean | true、false, 默认true | 是否显示左上角页码 |
backTop | Boolean | true、false, 默认true | 是否显示右下角回到顶部按钮 |
lazy | Boolean | true、false, 默认false | 是否开启懒加载(实际是延迟加载图片,即屏幕滚动到pdf位置时加载图片) |
maxZoom | Number | 最大倍数3 | 手势缩放最大倍数 |
scale | Number | 最大比例5,默认1.5 | pdf渲染的比例 |
scrollEnable | Boolean | true、false, 默认true | 是否允许pdf滚动 |
zoomEnable | Boolean | true、false, 默认true | 是否允许pdf手势缩放 |
cMapUrl | String | 默认"https://www.gjtool.cn/cmaps/" | 解析pdf时,特殊情况下显示完整字体的cmaps文件夹路径,例如 cMapUrl:"https://unpkg.com/pdfjs-dist@2.0.943/cmaps/" |
limit | Number | 默认0 | 限制pdf加载最大页数 |
logo | Object | {src:"pdfh5.png",x:10,y:10,width:40,height:40}src水印图片路径(建议使用png透明图片),width水印宽度,height水印高度,以每页pdf左上角为0点,x、y为偏移值。 默认false | 给每页pdf添加水印logo(canvas模式下使用) |
goto | Number | 默认0 | 加载pdf跳转到第几页 |
textLayer | Boolean | true、false, 默认false | 是否开启textLayer,可以复制文本(canvas模式下使用)【处于测试阶段,位置偏移严重】 |
background | Object | {color:"#fff",image:"url('pdfh5.png')",repeat:"no-repeat",position:"left top",size:"40px 40px"},和css的background属性语法相同,默认false | 是否开启背景图模式 |
参数名称 | 类型 | 取值 | 作用 |
---|---|---|---|
httpHeaders | Object | 默认空 | 设置httpHeaders信息 |
withCredentials | Boolean | 默认false | 是否使用cookie或授权标头之类的凭据发出跨站点访问 |
password | String | 默认空 | 用于访问有密码的PDF |
stopAtErrors | Boolean | 默认false | 当无法成功解析关联的PDF数据时,停止解析 |
disableFontFace | Boolean | 默认false | 默认情况下,字体会转换为OpenType字体,并通过字体规则来加载。如果禁用,字体将使用内置的字体渲染器渲染。 |
disableRange | Boolean | 默认false | 禁用范围请求加载PDF文件。启用后,如果服务器支持部分内容请求,则将以块的形式获取PDF。 |
disableStream | Boolean | 默认false | 禁用流式传输PDF文件数据。默认情况下,PDF.js尝试加载成块的PDF。 |
disableAutoFetch | Boolean | 默认false | 禁用PDF文件数据的预取。启用范围请求后,即使不需要显示当前页面,PDF.js也会自动继续获取更多数据。默认值为“ false”。注意:还必须禁用流传输disableStream |
1$.ajax({ 2 url: "https://www.gjtool.cn/pdfh5/git.pdf", //假设这是pdf文件流的请求接口 3 type: "get", 4 mimeType: 'text/plain; charset=x-user-defined',//jq ajax请求文件流的方式 5 success: function (data) { 6 var pdfh5 = new Pdfh5('#demo', { 7 data: data 8 }); 9 } 10});
1$.ajax({ 2 url: "https://www.gjtool.cn/pdfh5/git.pdf", //假设这是pdf文件流的请求接口 3 type: "get", 4 mimeType: 'text/plain; charset=x-user-defined',//jq ajax请求文件流的方式 5 success: function (data) { 6 var rawLength = data.length; 7 var array = new Uint8Array(new ArrayBuffer(rawLength)); 8 for (i = 0; i < rawLength; i++) { 9 array[i] = data.charCodeAt(i) & 0xff; 10 } 11 var pdfh5 = new Pdfh5('#demo', { 12 data: array 13 }); 14 } 15});
1$.ajax({ 2 url: "https://www.gjtool.cn/pdfh5/git.pdf", //假设这是pdf文件流的请求接口 3 type: "get", 4 mimeType: 'text/plain; charset=x-user-defined',//jq ajax请求文件流的方式 5 success: function (data) { 6 var rawLength = data.length; 7 var array = []; 8 for (i = 0; i < rawLength; i++) { 9 array.push(data.charCodeAt(i) & 0xff); 10 } 11 var pdfh5 = new Pdfh5('#demo', { 12 data: array 13 }); 14 } 15});
1axios.get("https://www.gjtool.cn/pdfh5/git.pdf",{ 2 responseType:"arraybuffer" 3}).then(res=>{ 4 this.pdfh5 = new Pdfh5('#demo', { 5 data: res.data 6 }); 7})
1let pdfBase64 = "adfxcvadfasdfxxxxx"; 2 3 new Pdfh5('#demo', { 4 pdfurl: "data:application/pdf;base64,"+pdfBase64, 5 });
1pdfh5.scrollEnable(true) //允许pdf滚动 2pdfh5.scrollEnable(false) //不允许pdf滚动
方法名 | 传参 | 传参取值 | 作用 |
---|---|---|---|
scrollEnable | Boolean | true、false, 默认true | 是否允许pdf滚动(需要在pdf加载完成后使用) |
zoomEnable | Boolean | true、false, 默认true | 是否允许pdf手势缩放(需要在pdf加载完成后使用) |
show | Function | 带一个回调函数 | pdfh5显示 |
hide | Function | 带一个回调函数 | pdfh5隐藏 |
reset | Function | 带一个回调函数 | pdfh5还原 |
destroy | Function | 带一个回调函数 | pdfh5销毁 |
on | (String, Function) | String:监听的事件名,Function:监听的事件回调 | on方法监听所有事件 |
goto | Number | Number:要跳转的pdf页数 | pdf跳转到第几页(pdf加载完成后使用) |
download | (String, Function) | String:下载pdf的名称,默认download.pdf,Function:下载完成后的回调 | 下载pdf |
1pdfh5.on("ready", function () { 2 console.log("总页数:" + this.totalNum) 3})
事件名 | 回调 | 作用 |
---|---|---|
init | Function | 监听pdfh5开始初始化 |
ready | Function | 监听pdf准备开始渲染,此时可以拿到pdf总页数 |
error | Function(msg,time) | 监听加载失败,msg信息,time耗时 |
success | Function(msg,time) | 监听pdf渲染成功,msg信息,time耗时 |
complete | Function(status, msg, time) | 监听pdf加载完成事件,加载失败、渲染成功都会触发。status有两种状态success和error |
render | Function(currentNum, time, currentPageDom) | 监听pdf渲染过程,currentPageDom当前加载的pdf的dom,currentNum当前加载的pdf页数, |
zoom | Function(scale) | 监听pdf缩放,scale缩放比例 |
scroll | Function(scrollTop,currentNum) | 监听pdf滚动,scrollTop滚动条高度,currentNum当前页码 |
backTop | Function | 监听回到顶部按钮的点击事件回调 |
zoomEnable | Function(flag) | 监听允许缩放,flag:true,false |
scrollEnable | Function(flag) | 监听允许滚动,flag:true,false |
show | Function | 监听pdfh5显示 |
hide | Function | 监听pdfh5隐藏 |
reset | Function | 监听pdfh5还原 |
destroy | Function | 监听pdfh5销毁 |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
Found 2/18 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More