├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── css ├── pdfh5.css └── style.css ├── example ├── react-test │ ├── .gitignore │ ├── README.md │ ├── build │ │ ├── favicon.ico │ │ ├── git.pdf │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── config │ │ ├── env.js │ │ ├── getHttpsConfig.js │ │ ├── jest │ │ │ ├── cssTransform.js │ │ │ └── fileTransform.js │ │ ├── modules.js │ │ ├── paths.js │ │ ├── pnpTs.js │ │ ├── webpack.config.js │ │ └── webpackDevServer.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── git.pdf │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── scripts │ │ ├── build.js │ │ ├── start.js │ │ └── test.js │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── pdf.js │ │ ├── serviceWorker.js │ │ └── setupTests.js │ └── yarn.lock ├── test │ ├── .babelrc │ ├── .editorconfig │ ├── .gitignore │ ├── .postcssrc.js │ ├── README.md │ ├── build │ │ ├── build.js │ │ ├── build2.js │ │ ├── check-versions.js │ │ ├── logo.png │ │ ├── utils.js │ │ ├── vue-loader.conf.js │ │ ├── webpack.base.conf.js │ │ ├── webpack.dev.conf.js │ │ └── webpack.prod.conf.js │ ├── config │ │ ├── dev.env.js │ │ ├── index.js │ │ └── prod.env.js │ ├── index.html │ ├── package.json │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ └── logo.png │ │ ├── components │ │ │ ├── HelloWorld.vue │ │ │ └── index.vue │ │ ├── main.js │ │ └── router │ │ │ └── index.js │ └── static │ │ ├── .gitkeep │ │ ├── git.pdf │ │ └── test.pdf ├── vite4vue3 │ ├── .gitignore │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ ├── git.pdf │ │ └── vite.svg │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ └── vue.svg │ │ ├── components │ │ │ └── HelloWorld.vue │ │ ├── main.ts │ │ ├── style.css │ │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts └── vue3demo │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── jsconfig.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── git.pdf │ └── index.html │ ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ └── HelloWorld.vue │ └── main.js │ └── vue.config.js ├── git.pdf ├── index.html ├── js ├── pdf.js ├── pdf.worker.js ├── pdfh5.js └── pdfh5.worker.js ├── package.json ├── pdf.html ├── pdfh5.png ├── test.pdf └── vconsole.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | pdf 4 | index 5 | git 6 | testPDF 7 | example 8 | fonts 9 | version 10 | test 11 | testPDF 12 | .github 13 | .vscode 14 | pdf/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | pdf 4 | index 5 | git 6 | testPDF 7 | example 8 | fonts 9 | version 10 | test 11 | testPDF 12 | .github 13 | .vscode 14 | pdf/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 4.4.4 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2018] [gjTool] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pdfh5.js 2 | [![npm version](https://img.shields.io/npm/v/pdfh5.svg)](https://www.npmjs.com/package/pdfh5) [![npm downloads](https://img.shields.io/npm/dt/pdfh5.svg)](https://www.npmjs.com/package/pdfh5) [![npm downloads](https://img.shields.io/npm/dw/pdfh5.svg)](https://www.npmjs.com/package/pdfh5) [![MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gjTool/pdfh5/blob/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/gjTool/pdfh5.svg)](https://github.com/gjTool/pdfh5/issues) [![GitHub stars](https://img.shields.io/github/stars/gjTool/pdfh5.svg?style=social)](https://github.com/gjTool/pdfh5/stargazers) [![GitHub forks](https://img.shields.io/github/forks/gjTool/pdfh5.svg?style=social)](https://github.com/gjTool/pdfh5/network/members) 3 | 4 | **1、有问题可以加Q群咨询,技术交流群,也可以探讨技术,另有微信群可以问群主拉入微信群** 5 | 6 | **2、如果有报错,请复制example运行,然后对照相关文件,以及package.json,缺什么补什么** 7 | 8 | **3、如果有某些字体显示不了,那可能是pdf.js缺少相关字库解析,可以尝试更改cMapUrl,建议去官方地址找版本** 9 | 10 | **4、如果IOS下pdf显示不了,安卓却可以,可能是pdf精度过高导致,Safari浏览器canvas渲染绘制图片宽高不能超过16777216,超过会不显示** 11 | 12 | 13 | - [QQ群521681398](https://qm.qq.com/cgi-bin/qm/qr?k=3_qouxqe5w3gRCcHjpqkwtx-4yS6QSPD&jump_from=webapi&authKey=FlHU4wH2xOQUthUpgF5W3b1VXowCVmSRfJLU4GRcDVyBayJd1ank4HkOWSZei2f3) 14 | - [pdfh5博客主页](https://pdfh5.gjtool.cn/) 15 | 16 | - [pdfh5项目GitHub地址](https://github.com/gjTool/pdfh5) 17 | 18 | - [pdfh5项目gitee地址](https://gitee.com/gjTool/pdfh5) 19 | 20 | 21 | #### react、vue均可使用 22 | #### [example/test](https://github.com/gjTool/pdfh5/tree/master/example/test)是vue使用示例 23 | #### [example/vue3demo](https://github.com/gjTool/pdfh5/tree/master/example/vue3demo)是vue3使用示例 24 | #### [example/vite4vue3](https://github.com/gjTool/pdfh5/tree/master/example/vite4vue3)是vite4+vue3+ts使用示例 25 | #### [example/react-test](https://github.com/gjTool/pdfh5/tree/master/example/react-test)是react使用示例 26 | 27 | ![pdfh5.js示例](https://pdfh5.gjtool.cn/img/123.gif) 28 | 29 | ## 更新信息 30 | - 2025.05.18 更新: 修复调用updateFile方法后,原先监听事件失效的问题。修复scroll事件监听最后一页的问题。 31 | - 2025.05.13 更新: 新增方法updateFile更新pdf,修复destroy报错。 32 | - 2025.05.09 更新: 优化放大后的手势水平滚动。 33 | - 2025.05.07 更新: 移除jQuery依赖,img渲染还原成canvas渲染,合并textLayer的PR,所有示例同步更新,修复部分bugs。 34 | 35 | ### pdfh5在线预览 (建议使用谷歌浏览器F12手机模式打开预览) 36 | 37 | - [https://pdfh5.gjtool.cn/pdfh5/pdf.html?file=https://pdfh5.gjtool.cn/pdfh5/git.pdf](https://pdfh5.gjtool.cn/pdfh5/pdf.html?file=https://pdfh5.gjtool.cn/pdfh5/git.pdf) 38 | 39 | 40 | ## 快速使用(有两种方式) 41 | 42 | #### 一、script标签引入方式 43 | 44 | - 1.创建div 45 | 46 | ```javascript 47 |
48 | ``` 49 | 50 | - 2.依次引入js(需引用本项目的js,不要引用官方的pdf.js避免官方版本api没有向下兼容) 51 | 52 | ```javascript 53 | 54 | 55 | 56 | ``` 57 | 58 | - 3.实例化 59 | 60 | ```javascript 61 | var pdfh5 = new Pdfh5(document.querySelector("#demo"), { 62 | pdfurl: "./default.pdf" 63 | }); 64 | ``` 65 | 66 | #### 二、npm安装方式(适应于vue), react使用方法类似vue(example/react-test是react使用示例) 67 | 68 | - 1.安装 69 | 70 | ```javascript 71 | npm install pdfh5 72 | ``` 73 | - 2.使用 74 | 75 | ```javascript 76 | 81 | 106 | 107 | 117 | ``` 118 | 119 | 120 | # API接口方法 121 | 122 | 123 | ## 实例化 124 | - **pdfh5实例化的时候传两个参数,selector选择器,options配置项参数,会返回一个pdfh5实例对象,可以用来操作pdf,监听相关事件** 125 | ```javascript 126 | var pdfh5 = new Pdfh5(selector, options); 127 | ``` 128 | |参数名称 |类型 |取值 |是否必须 |作用 | 129 | |:---:|:---:|:---:|:---:|:---:| 130 | |selector | HTMLElement | - | √ |pdfh5的容器,html DOM元素对象 | 131 | |options | Object | - | × |pdfh5的配置项参数 | 132 | 133 | ## options配置项参数列表 134 | 135 | - **示例:** 配置项参数 pdfurl 136 | 137 | ```javascript 138 | var pdfh5 = new Pdfh5(document.querySelector("#demo"), { 139 | pdfurl: "./default.pdf" 140 | }); 141 | ``` 142 | 143 | |参数名称 |类型 |取值 |作用 | 144 | |:---:|:---:|:---:|:---:| 145 | |pdfurl | String | - |pdf地址 | 146 | |responseType | String |blob 、 arraybuffer 默认 blob |请求pdf数据格式 | 147 | |URIenable | Boolean |true、false, 默认false | true开启地址栏file参数 | 148 | |data | Array(arraybuffer) | - |pdf文件流 ,与pdfurl二选一(二进制PDF数据。使用类型化数组(Uint8Array)可以提高内存使用率。如果PDF数据是BASE64编码的,请先使用atob()将其转换为二进制字符串。) | 149 | |renderType | String |"canvas"、"svg",默认"canvas" |pdf渲染模式 | 150 | |pageNum | Boolean |true、false, 默认true |是否显示左上角页码 | 151 | |backTop | Boolean |true、false, 默认true |是否显示右下角回到顶部按钮 | 152 | |maxZoom | Number |最大倍数3 |手势缩放最大倍数 | 153 | |scale | Number |最大比例5,默认1.5 |pdf渲染的比例 | 154 | |scrollEnable | Boolean |true、false, 默认true |是否允许pdf滚动 | 155 | |zoomEnable | Boolean |true、false, 默认true |是否允许pdf手势缩放 | 156 | |cMapUrl | String | " |解析pdf时,特殊情况下显示完整字体的cmaps文件夹路径,例如 cMapUrl:"https://unpkg.com/pdfjs-dist@2.0.943/cmaps/" | 157 | |limit | Number | 默认0 |限制pdf加载最大页数 | 158 | |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模式下使用) | 159 | |goto | Number | 默认0 |加载pdf跳转到第几页 | 160 | |textLayer | Boolean | true、false, 默认false |是否开启textLayer,可以复制文本(canvas模式下使用)】 | 161 | |background | Object | {color:"#fff",image:"url('pdfh5.png')",repeat:"no-repeat",position:"left top",size:"40px 40px"},和css的background属性语法相同,默认false |是否开启背景图模式 | 162 | 163 | ## pdf请求示例 164 | 1、文件地址 165 | ```javascript 166 | new Pdfh5(document.querySelector("#demo"), { 167 | pdfurl: "git.pdf", 168 | // responseType: "blob" // blob arraybuffer 169 | }); 170 | ``` 171 | 172 | 173 | 2、pdf文件流或者buffer已经得到,如何渲染 174 | ```javascript 175 | new Pdfh5(document.querySelector("#demo"), { 176 | data: blob, //blob arraybuffer 177 | }); 178 | ``` 179 | ## methods 方法列表 180 | 181 | - **示例:** 是否允许pdf滚动 182 | 183 | ```javascript 184 | pdfh5.scrollEnable(true) //允许pdf滚动 185 | pdfh5.scrollEnable(false) //不允许pdf滚动 186 | ``` 187 | 188 | |方法名 |传参 |传参取值 |作用 | 189 | |:---:|:---:|:---:|:---:| 190 | |scrollEnable | Boolean |true、false, 默认true |是否允许pdf滚动(需要在pdf加载完成后使用) | 191 | |zoomEnable | Boolean |true、false, 默认true |是否允许pdf手势缩放(需要在pdf加载完成后使用) | 192 | |show | Function |带一个回调函数 |pdfh5显示 | 193 | |hide | Function |带一个回调函数 |pdfh5隐藏 | 194 | |reset | Function |带一个回调函数 |pdfh5还原 | 195 | |destroy | Function |带一个回调函数 |pdfh5销毁 | 196 | |on | (String, Function)|String:监听的事件名,Function:监听的事件回调 |on方法监听所有事件 | 197 | |goto | Number |Number:要跳转的pdf页数 |pdf跳转到第几页(pdf加载完成后使用) | 198 | |download | (String, Function)|String:下载pdf的名称,默认download.pdf,Function:下载完成后的回调|下载pdf | 199 | |updateFile | options |options.pdfurl:要更新的pdf地址,options.data:要更新的pdf文件流(blob 、 arraybuffer )|更新pdf 200 | ## on方法监听所有事件-事件名列表 201 | 202 | - **示例:** 监听pdf准备开始渲染,此时可以拿到pdf总页数 203 | 204 | ```javascript 205 | pdfh5.on("ready", function () { 206 | console.log("总页数:" + this.totalNum) 207 | }) 208 | ``` 209 | |事件名 |回调 |作用 | 210 | |:---:|:---:|:---:| 211 | |init | Function |监听pdfh5开始初始化 | 212 | |ready | Function |监听pdf准备开始渲染,此时可以拿到pdf总页数 | 213 | |error | Function(msg,time) |监听加载失败,msg信息,time耗时 | 214 | |success | Function(msg,time) | 监听pdf渲染成功,msg信息,time耗时 | 215 | |complete | Function(status, msg, time) | 监听pdf加载完成事件,加载失败、渲染成功都会触发。status有两种状态success和error | 216 | |render | Function(currentNum, time, currentPageDom) | 监听pdf渲染过程,currentPageDom当前加载的pdf的dom,currentNum当前加载的pdf页数, | 217 | |zoom | Function(scale) | 监听pdf缩放,scale缩放比例 | 218 | |scroll | Function(scrollTop,currentNum) | 监听pdf滚动,scrollTop滚动条高度,currentNum当前页码 | 219 | |backTop | Function | 监听回到顶部按钮的点击事件回调 | 220 | |zoomEnable | Function(flag) | 监听允许缩放,flag:true,false | 221 | |scrollEnable | Function(flag) | 监听允许滚动,flag:true,false | 222 | |show | Function | 监听pdfh5显示 | 223 | |hide | Function | 监听pdfh5隐藏 | 224 | |reset | Function | 监听pdfh5还原 | 225 | |destroy | Function | 监听pdfh5销毁 | 226 | 227 | ## 打赏榜单 228 | - [JayLin](https://github.com/110117ab) ¥6.66 229 | - [靓仔城](https://github.com/ljc7877376) ¥6.67 230 | - 南蓝 ¥8.80 231 | - 我是太阳 ¥29.99 232 | - *小波 ¥1.00 233 | - *鑫 ¥9.99 234 | - *手 ¥9.99 235 | - *勇 ¥19.99 236 | - *爷 ¥5.00 237 | - *超 ¥20.00 238 | - 3*Y ¥5.00 239 | - *阳 ¥5.00 240 | - **雄 ¥5.00 241 | - A*r ¥1.23 242 | - *客 ¥5.00 243 | - *运 ¥66.66 244 | - *辰 ¥30.00 245 | - *黎 ¥6.66+¥5.00 246 | - **福 ¥6.66 247 | - *🏀 ¥6.66+¥1.00 248 | - *阳 ¥10.00 249 | - 自闭中 ¥16.66+¥16.00 250 | - *焕 ¥6.66 251 | - *人 ¥5.00 252 | - *。 ¥5.20 253 | - 半*) ¥5.00 254 | - *1 ¥15.00 255 | - *蕾 ¥16.66+¥8.80 256 | - *军 ¥10.00 257 | - **强 ¥58.88 258 | - E*y ¥6.60 259 | - J*u ¥13.00 260 | - A*a ¥50.00 261 | - *东 ¥8.80 262 | - j*y ¥9.99 263 | - *宇 ¥6.66 264 | - *涛 ¥1.00 265 | - *. ¥10.00 266 | - *☺ ¥6.66 267 | - *霸 ¥6.66 268 | - a*r ¥20.00 269 | - 木槿(**耀) ¥50.00 270 | -------------------------------------------------------------------------------- /css/pdfh5.css: -------------------------------------------------------------------------------- 1 | .pdfjs { 2 | width: 100%; 3 | height: 100%; 4 | overflow: hidden; 5 | background: #fff; 6 | position: relative; 7 | } 8 | 9 | .pdfjs .viewerContainer { 10 | position: relative; 11 | width: 100%; 12 | height: 100%; 13 | overflow: auto; 14 | -webkit-overflow-scrolling: touch; 15 | transition: all .3s; 16 | } 17 | 18 | .pdfjs .pdfViewer { 19 | position: relative; 20 | top: 0; 21 | left: 0; 22 | padding: 10px 8px; 23 | } 24 | 25 | .pdfjs .pdfViewer .pageContainer { 26 | width: 100%; 27 | margin: 0px auto 8px auto; 28 | position: relative; 29 | overflow: visible; 30 | -webkit-box-shadow: darkgrey 0px 1px 3px 0px; 31 | -moz-box-shadow: darkgrey 0px 1px 3px 0px; 32 | box-shadow: darkgrey 0px 1px 3px 0px; 33 | background-color: white; 34 | box-sizing: border-box; 35 | } 36 | 37 | .pdfjs .pdfViewer .pageContainer img { 38 | width: 100%; 39 | height: 100%; 40 | position: relative; 41 | z-index: 100; 42 | user-select: none; 43 | } 44 | 45 | .pdfjs .pdfViewer .pageContainer canvas { 46 | width: 100%; 47 | height: 100%; 48 | position: relative; 49 | z-index: 100; 50 | user-select: none; 51 | } 52 | 53 | .pdfjs .pageNum { 54 | padding: 0px 7px; 55 | height: 26px; 56 | position: absolute; 57 | top: 20px; 58 | left: 15px; 59 | z-index: 997; 60 | border-radius: 8px; 61 | transition: all .3s; 62 | display: none; 63 | } 64 | 65 | .pdfjs .pageNum-bg, 66 | .pdfjs .pageNum-num { 67 | width: 100%; 68 | height: 100%; 69 | line-height: 26px; 70 | text-align: center; 71 | position: absolute; 72 | top: 0px; 73 | left: 0px; 74 | color: #fff; 75 | border-radius: 8px; 76 | font-size: 16px; 77 | } 78 | 79 | .pdfjs .pageNum-bg { 80 | background: rgba(0, 0, 0, 0.5); 81 | } 82 | 83 | .pdfjs .pageNum-num { 84 | position: relative; 85 | } 86 | 87 | .pdfjs .pageNum span { 88 | color: #fff; 89 | font-size: 16px; 90 | } 91 | 92 | .pdfjs .loadingBar { 93 | position: absolute; 94 | width: 100%; 95 | z-index: 99; 96 | background: #fff !important; 97 | height: 4px; 98 | top: 0px; 99 | left: 0px; 100 | transition: all .3s; 101 | } 102 | 103 | .pdfjs .loadingBar .progress { 104 | background: #fff !important; 105 | position: absolute; 106 | top: 0; 107 | left: 0; 108 | width: 0%; 109 | height: 100%; 110 | overflow: hidden; 111 | transition: width 200ms; 112 | } 113 | 114 | .pdfjs .loadingBar .progress .glimmer { 115 | position: absolute; 116 | top: 0; 117 | left: 0; 118 | height: 100%; 119 | width: calc(100% + 150px); 120 | background: #7bcf34; 121 | } 122 | 123 | .pdfjs .backTop { 124 | width: 50px; 125 | height: 50px; 126 | line-height: 50px; 127 | text-align: center; 128 | position: absolute; 129 | bottom: 90px; 130 | right: 15px; 131 | font-size: 18px; 132 | z-index: 999; 133 | border-radius: 50%; 134 | background: rgba(0, 0, 0, 0.4) url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsSAAALEgHS3X78AAAA+klEQVRYw+2WUQ2DMBCG2TIBSJiESkACEpCAg83BcLBJmIQ5gClgDpiDby9tciGkoaUtZOESXuhdv7+X/pdm2dYC6IgX7Zh3THy+w9oN/rMASqBcE26iSA1XwCAEDIBKBc8F/KE/gB7IU8BbDXyJf2Z2tFFFAE8N6iRIi/jotXssuGn1FzhPrCu9BtCEhlcCrix5hbiYVSh46bKpELvcniO71Q51zWJ7ju3mUe9vzym7eR7Az57CbohTXBzAt9GknG9PoLY8KK4z6htLfeXTTXMZAfoZuWYWKC+YZWMAQuWZSP0k2wXsAnYB2xNwci1wGTKhO/COlLtu/ABVfTFsxwwYRgAAAABJRU5ErkJggg==) no-repeat center; 135 | background-size: 50% 50%; 136 | transition: all .3s; 137 | display: none; 138 | } 139 | 140 | .pdfjs .loadEffect { 141 | width: 100px; 142 | height: 100px; 143 | position: absolute; 144 | top: 50%; 145 | left: 50%; 146 | margin-top: -50px; 147 | margin-left: -50px; 148 | z-index: 99; 149 | background: url(data:image/gif;base64,R0lGODlhgACAAKIAAP///93d3bu7u5mZmQAA/wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAEACwCAAIAfAB8AAAD/0i63P4wyg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HDQKmw571l8my+16v+CweEwum8+hgHrNbrvbtrd8znbR73MVfg838f8BeoB7doN0cYZvaIuMjY6PkJGSk2gClgJml5pjmp2YYJ6dX6GeXaShWaeoVqqlU62ir7CXqbOWrLafsrNctjIDwAMWvC7BwRWtNsbGFKc+y8fNsTrQ0dK3QtXAYtrCYd3eYN3c49/a5NVj5eLn5u3s6e7x8NDo9fbL+Mzy9/T5+tvUzdN3Zp+GBAAh+QQJBQAEACwCAAIAfAB8AAAD/0i63P4wykmrvTjrzbv/YCiOZGmeaKqubOu+cCzPdArcQK2TOL7/nl4PSMwIfcUk5YhUOh3M5nNKiOaoWCuWqt1Ou16l9RpOgsvEMdocXbOZ7nQ7DjzTaeq7zq6P5fszfIASAYUBIYKDDoaGIImKC4ySH3OQEJKYHZWWi5iZG0ecEZ6eHEOio6SfqCaqpaytrpOwJLKztCO2jLi1uoW8Ir6/wCHCxMG2x7muysukzb230M6H09bX2Nna29zd3t/g4cAC5OXm5+jn3Ons7eba7vHt2fL16tj2+QL0+vXw/e7WAUwnrqDBgwgTKlzIsKHDh2gGSBwAccHEixAvaqTYcFCjRoYeNyoM6REhyZIHT4o0qPIjy5YTTcKUmHImx5cwE85cmJPnSYckK66sSAAj0aNIkypdyrSp06dQo0qdSrWq1atYs2rdyrWr169gwxZJAAA7) no-repeat center; 150 | background-size: 30% 30%; 151 | transition: all .3s; 152 | } 153 | 154 | .pdfjs .pdfViewer .pageContainer img.pdfLogo { 155 | /* user-select:none; */ 156 | position: absolute; 157 | z-index: 101; 158 | } 159 | 160 | .pdfjs .pdfViewer .pageContainer canvas.pdfLogo { 161 | /* user-select:none; */ 162 | position: absolute; 163 | z-index: 101; 164 | } 165 | 166 | .pdfjs .textLayer { 167 | position: absolute; 168 | left: 0; 169 | top: 0; 170 | right: 0; 171 | bottom: 0; 172 | overflow: hidden; 173 | opacity: 0.2; 174 | line-height: 1.0; 175 | z-index: 101; 176 | user-select: text; 177 | } 178 | 179 | .pdfjs .textLayer>br::selection { 180 | background-color: transparent !important; 181 | } 182 | 183 | .pdfjs .textLayer>span { 184 | color: transparent; 185 | position: absolute; 186 | white-space: pre; 187 | cursor: text; 188 | transform-origin: 0% 0%; 189 | } 190 | 191 | .pdfjs .textLayer .highlight { 192 | margin: -1px; 193 | padding: 1px; 194 | background-color: rgba(180, 0, 170, 1); 195 | border-radius: 4px; 196 | } 197 | 198 | .pdfjs .textLayer .highlight.begin { 199 | border-radius: 4px 0px 0px 4px; 200 | } 201 | 202 | .pdfjs .textLayer .highlight.end { 203 | border-radius: 0px 4px 4px 0px; 204 | } 205 | 206 | .pdfjs .textLayer .highlight.middle { 207 | border-radius: 0px; 208 | } 209 | 210 | .pdfjs .textLayer .highlight.selected { 211 | background-color: rgba(0, 100, 0, 1); 212 | } 213 | 214 | .pdfjs .textLayer ::selection { 215 | background: rgba(0, 0, 255, 1); 216 | } 217 | 218 | .pdfjs .textLayer .endOfContent { 219 | display: block; 220 | position: absolute; 221 | left: 0px; 222 | top: 100%; 223 | right: 0px; 224 | bottom: 0px; 225 | z-index: -1; 226 | cursor: default; 227 | /* user-select: none; */ 228 | } 229 | 230 | .pdfjs .textLayer .endOfContent.active { 231 | top: 0px; 232 | } -------------------------------------------------------------------------------- /example/react-test/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /example/react-test/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /example/react-test/build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/react-test/build/favicon.ico -------------------------------------------------------------------------------- /example/react-test/build/git.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/react-test/build/git.pdf -------------------------------------------------------------------------------- /example/react-test/build/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/react-test/build/logo192.png -------------------------------------------------------------------------------- /example/react-test/build/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/react-test/build/logo512.png -------------------------------------------------------------------------------- /example/react-test/build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /example/react-test/build/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /example/react-test/config/env.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const paths = require('./paths'); 6 | 7 | // Make sure that including paths.js after env.js will read .env variables. 8 | delete require.cache[require.resolve('./paths')]; 9 | 10 | const NODE_ENV = process.env.NODE_ENV; 11 | if (!NODE_ENV) { 12 | throw new Error( 13 | 'The NODE_ENV environment variable is required but was not specified.' 14 | ); 15 | } 16 | 17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use 18 | const dotenvFiles = [ 19 | `${paths.dotenv}.${NODE_ENV}.local`, 20 | `${paths.dotenv}.${NODE_ENV}`, 21 | // Don't include `.env.local` for `test` environment 22 | // since normally you expect tests to produce the same 23 | // results for everyone 24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`, 25 | paths.dotenv, 26 | ].filter(Boolean); 27 | 28 | // Load environment variables from .env* files. Suppress warnings using silent 29 | // if this file is missing. dotenv will never modify any environment variables 30 | // that have already been set. Variable expansion is supported in .env files. 31 | // https://github.com/motdotla/dotenv 32 | // https://github.com/motdotla/dotenv-expand 33 | dotenvFiles.forEach(dotenvFile => { 34 | if (fs.existsSync(dotenvFile)) { 35 | require('dotenv-expand')( 36 | require('dotenv').config({ 37 | path: dotenvFile, 38 | }) 39 | ); 40 | } 41 | }); 42 | 43 | // We support resolving modules according to `NODE_PATH`. 44 | // This lets you use absolute paths in imports inside large monorepos: 45 | // https://github.com/facebook/create-react-app/issues/253. 46 | // It works similar to `NODE_PATH` in Node itself: 47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 49 | // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. 50 | // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 51 | // We also resolve them to make sure all tools using them work consistently. 52 | const appDirectory = fs.realpathSync(process.cwd()); 53 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 54 | .split(path.delimiter) 55 | .filter(folder => folder && !path.isAbsolute(folder)) 56 | .map(folder => path.resolve(appDirectory, folder)) 57 | .join(path.delimiter); 58 | 59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 60 | // injected into the application via DefinePlugin in webpack configuration. 61 | const REACT_APP = /^REACT_APP_/i; 62 | 63 | function getClientEnvironment(publicUrl) { 64 | const raw = Object.keys(process.env) 65 | .filter(key => REACT_APP.test(key)) 66 | .reduce( 67 | (env, key) => { 68 | env[key] = process.env[key]; 69 | return env; 70 | }, 71 | { 72 | // Useful for determining whether we’re running in production mode. 73 | // Most importantly, it switches React into the correct mode. 74 | NODE_ENV: process.env.NODE_ENV || 'development', 75 | // Useful for resolving the correct path to static assets in `public`. 76 | // For example, . 77 | // This should only be used as an escape hatch. Normally you would put 78 | // images into the `src` and `import` them in code to get their paths. 79 | PUBLIC_URL: publicUrl, 80 | // We support configuring the sockjs pathname during development. 81 | // These settings let a developer run multiple simultaneous projects. 82 | // They are used as the connection `hostname`, `pathname` and `port` 83 | // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` 84 | // and `sockPort` options in webpack-dev-server. 85 | WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, 86 | WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, 87 | WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, 88 | } 89 | ); 90 | // Stringify all values so we can feed into webpack DefinePlugin 91 | const stringified = { 92 | 'process.env': Object.keys(raw).reduce((env, key) => { 93 | env[key] = JSON.stringify(raw[key]); 94 | return env; 95 | }, {}), 96 | }; 97 | 98 | return { raw, stringified }; 99 | } 100 | 101 | module.exports = getClientEnvironment; 102 | -------------------------------------------------------------------------------- /example/react-test/config/getHttpsConfig.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const crypto = require('crypto'); 6 | const chalk = require('react-dev-utils/chalk'); 7 | const paths = require('./paths'); 8 | 9 | // Ensure the certificate and key provided are valid and if not 10 | // throw an easy to debug error 11 | function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { 12 | let encrypted; 13 | try { 14 | // publicEncrypt will throw an error with an invalid cert 15 | encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); 16 | } catch (err) { 17 | throw new Error( 18 | `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` 19 | ); 20 | } 21 | 22 | try { 23 | // privateDecrypt will throw an error with an invalid key 24 | crypto.privateDecrypt(key, encrypted); 25 | } catch (err) { 26 | throw new Error( 27 | `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ 28 | err.message 29 | }` 30 | ); 31 | } 32 | } 33 | 34 | // Read file and throw an error if it doesn't exist 35 | function readEnvFile(file, type) { 36 | if (!fs.existsSync(file)) { 37 | throw new Error( 38 | `You specified ${chalk.cyan( 39 | type 40 | )} in your env, but the file "${chalk.yellow(file)}" can't be found.` 41 | ); 42 | } 43 | return fs.readFileSync(file); 44 | } 45 | 46 | // Get the https config 47 | // Return cert files if provided in env, otherwise just true or false 48 | function getHttpsConfig() { 49 | const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; 50 | const isHttps = HTTPS === 'true'; 51 | 52 | if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { 53 | const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); 54 | const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); 55 | const config = { 56 | cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), 57 | key: readEnvFile(keyFile, 'SSL_KEY_FILE'), 58 | }; 59 | 60 | validateKeyAndCerts({ ...config, keyFile, crtFile }); 61 | return config; 62 | } 63 | return isHttps; 64 | } 65 | 66 | module.exports = getHttpsConfig; 67 | -------------------------------------------------------------------------------- /example/react-test/config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/en/webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /example/react-test/config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const camelcase = require('camelcase'); 5 | 6 | // This is a custom Jest transformer turning file imports into filenames. 7 | // http://facebook.github.io/jest/docs/en/webpack.html 8 | 9 | module.exports = { 10 | process(src, filename) { 11 | const assetFilename = JSON.stringify(path.basename(filename)); 12 | 13 | if (filename.match(/\.svg$/)) { 14 | // Based on how SVGR generates a component name: 15 | // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 16 | const pascalCaseFilename = camelcase(path.parse(filename).name, { 17 | pascalCase: true, 18 | }); 19 | const componentName = `Svg${pascalCaseFilename}`; 20 | return `const React = require('react'); 21 | module.exports = { 22 | __esModule: true, 23 | default: ${assetFilename}, 24 | ReactComponent: React.forwardRef(function ${componentName}(props, ref) { 25 | return { 26 | $$typeof: Symbol.for('react.element'), 27 | type: 'svg', 28 | ref: ref, 29 | key: null, 30 | props: Object.assign({}, props, { 31 | children: ${assetFilename} 32 | }) 33 | }; 34 | }), 35 | };`; 36 | } 37 | 38 | return `module.exports = ${assetFilename};`; 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/react-test/config/modules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const paths = require('./paths'); 6 | const chalk = require('react-dev-utils/chalk'); 7 | const resolve = require('resolve'); 8 | 9 | /** 10 | * Get additional module paths based on the baseUrl of a compilerOptions object. 11 | * 12 | * @param {Object} options 13 | */ 14 | function getAdditionalModulePaths(options = {}) { 15 | const baseUrl = options.baseUrl; 16 | 17 | // We need to explicitly check for null and undefined (and not a falsy value) because 18 | // TypeScript treats an empty string as `.`. 19 | if (baseUrl == null) { 20 | // If there's no baseUrl set we respect NODE_PATH 21 | // Note that NODE_PATH is deprecated and will be removed 22 | // in the next major release of create-react-app. 23 | 24 | const nodePath = process.env.NODE_PATH || ''; 25 | return nodePath.split(path.delimiter).filter(Boolean); 26 | } 27 | 28 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl); 29 | 30 | // We don't need to do anything if `baseUrl` is set to `node_modules`. This is 31 | // the default behavior. 32 | if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { 33 | return null; 34 | } 35 | 36 | // Allow the user set the `baseUrl` to `appSrc`. 37 | if (path.relative(paths.appSrc, baseUrlResolved) === '') { 38 | return [paths.appSrc]; 39 | } 40 | 41 | // If the path is equal to the root directory we ignore it here. 42 | // We don't want to allow importing from the root directly as source files are 43 | // not transpiled outside of `src`. We do allow importing them with the 44 | // absolute path (e.g. `src/Components/Button.js`) but we set that up with 45 | // an alias. 46 | if (path.relative(paths.appPath, baseUrlResolved) === '') { 47 | return null; 48 | } 49 | 50 | // Otherwise, throw an error. 51 | throw new Error( 52 | chalk.red.bold( 53 | "Your project's `baseUrl` can only be set to `src` or `node_modules`." + 54 | ' Create React App does not support other values at this time.' 55 | ) 56 | ); 57 | } 58 | 59 | /** 60 | * Get webpack aliases based on the baseUrl of a compilerOptions object. 61 | * 62 | * @param {*} options 63 | */ 64 | function getWebpackAliases(options = {}) { 65 | const baseUrl = options.baseUrl; 66 | 67 | if (!baseUrl) { 68 | return {}; 69 | } 70 | 71 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl); 72 | 73 | if (path.relative(paths.appPath, baseUrlResolved) === '') { 74 | return { 75 | src: paths.appSrc, 76 | }; 77 | } 78 | } 79 | 80 | /** 81 | * Get jest aliases based on the baseUrl of a compilerOptions object. 82 | * 83 | * @param {*} options 84 | */ 85 | function getJestAliases(options = {}) { 86 | const baseUrl = options.baseUrl; 87 | 88 | if (!baseUrl) { 89 | return {}; 90 | } 91 | 92 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl); 93 | 94 | if (path.relative(paths.appPath, baseUrlResolved) === '') { 95 | return { 96 | '^src/(.*)$': '/src/$1', 97 | }; 98 | } 99 | } 100 | 101 | function getModules() { 102 | // Check if TypeScript is setup 103 | const hasTsConfig = fs.existsSync(paths.appTsConfig); 104 | const hasJsConfig = fs.existsSync(paths.appJsConfig); 105 | 106 | if (hasTsConfig && hasJsConfig) { 107 | throw new Error( 108 | 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' 109 | ); 110 | } 111 | 112 | let config; 113 | 114 | // If there's a tsconfig.json we assume it's a 115 | // TypeScript project and set up the config 116 | // based on tsconfig.json 117 | if (hasTsConfig) { 118 | const ts = require(resolve.sync('typescript', { 119 | basedir: paths.appNodeModules, 120 | })); 121 | config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; 122 | // Otherwise we'll check if there is jsconfig.json 123 | // for non TS projects. 124 | } else if (hasJsConfig) { 125 | config = require(paths.appJsConfig); 126 | } 127 | 128 | config = config || {}; 129 | const options = config.compilerOptions || {}; 130 | 131 | const additionalModulePaths = getAdditionalModulePaths(options); 132 | 133 | return { 134 | additionalModulePaths: additionalModulePaths, 135 | webpackAliases: getWebpackAliases(options), 136 | jestAliases: getJestAliases(options), 137 | hasTsConfig, 138 | }; 139 | } 140 | 141 | module.exports = getModules(); 142 | -------------------------------------------------------------------------------- /example/react-test/config/paths.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const fs = require('fs'); 5 | const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); 6 | 7 | // Make sure any symlinks in the project folder are resolved: 8 | // https://github.com/facebook/create-react-app/issues/637 9 | const appDirectory = fs.realpathSync(process.cwd()); 10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 11 | 12 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 13 | // "public path" at which the app is served. 14 | // webpack needs to know it to put the right 27 | 28 | 42 | -------------------------------------------------------------------------------- /example/test/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/test/src/assets/logo.png -------------------------------------------------------------------------------- /example/test/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 85 | 86 | 96 | 97 | 98 | 114 | -------------------------------------------------------------------------------- /example/test/src/components/index.vue: -------------------------------------------------------------------------------- 1 | 11 | 18 | -------------------------------------------------------------------------------- /example/test/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | import router from './router' 4 | 5 | Vue.config.productionTip = false 6 | 7 | /* eslint-disable no-new */ 8 | new Vue({ 9 | el: '#app', 10 | router, 11 | render: h => h(App) 12 | }) 13 | -------------------------------------------------------------------------------- /example/test/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import HelloWorld from '@/components/HelloWorld' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'HelloWorld', 12 | component: HelloWorld 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /example/test/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/test/static/.gitkeep -------------------------------------------------------------------------------- /example/test/static/git.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/test/static/git.pdf -------------------------------------------------------------------------------- /example/test/static/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/test/static/test.pdf -------------------------------------------------------------------------------- /example/vite4vue3/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /example/vite4vue3/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + TypeScript + Vite 2 | 3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/vite4vue3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite4vue3", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite --host", 8 | "build": "vue-tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "dommatrix": "^1.0.3", 13 | "pdfh5": "^2.0.2", 14 | "vue": "^3.3.4", 15 | "web-streams-polyfill": "^3.2.1", 16 | "canvas": "^2.11.2", 17 | "path2d-polyfill": "^2.0.1" 18 | }, 19 | "peerDependencies": { 20 | "worker-loader": "^3.0.8" 21 | }, 22 | "peerDependenciesMeta": { 23 | "worker-loader": { 24 | "optional": true 25 | } 26 | }, 27 | "optionalDependencies": { 28 | "canvas": "^2.11.2", 29 | "path2d-polyfill": "^2.0.1" 30 | }, 31 | "browser": { 32 | "canvas": false, 33 | "fs": false, 34 | "http": false, 35 | "https": false, 36 | "url": false, 37 | "zlib": false 38 | }, 39 | "format": "amd", 40 | "devDependencies": { 41 | "@vitejs/plugin-vue": "^4.2.3", 42 | "typescript": "^5.0.2", 43 | "vite": "^4.4.0", 44 | "vue-tsc": "^1.8.3" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /example/vite4vue3/public/git.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/vite4vue3/public/git.pdf -------------------------------------------------------------------------------- /example/vite4vue3/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/vite4vue3/src/App.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 16 | 17 | 23 | -------------------------------------------------------------------------------- /example/vite4vue3/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/vite4vue3/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 33 | 34 | 39 | -------------------------------------------------------------------------------- /example/vite4vue3/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import 'pdfh5/css/pdfh5.css'; 4 | import App from './App.vue' 5 | 6 | createApp(App).mount('#app') 7 | -------------------------------------------------------------------------------- /example/vite4vue3/src/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | 6 | html, 7 | body, 8 | #app { 9 | width: 100%; 10 | height: 100%; 11 | } 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/vite4vue3/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module "pdfh5" { 3 | import Pdfh5 from 'pdfh5' 4 | export default Pdfh5 5 | } -------------------------------------------------------------------------------- /example/vite4vue3/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | "types": ["node"], 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | }, 23 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], 24 | "references": [{ 25 | "path": "./tsconfig.node.json" 26 | }] 27 | } -------------------------------------------------------------------------------- /example/vite4vue3/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /example/vite4vue3/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()] 7 | }) -------------------------------------------------------------------------------- /example/vue3demo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /example/vue3demo/README.md: -------------------------------------------------------------------------------- 1 | # vue3demo 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /example/vue3demo/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /example/vue3demo/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "baseUrl": "./", 6 | "moduleResolution": "node", 7 | "paths": { 8 | "@/*": [ 9 | "src/*" 10 | ] 11 | }, 12 | "lib": [ 13 | "esnext", 14 | "dom", 15 | "dom.iterable", 16 | "scripthost" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/vue3demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue3demo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "^3.8.3", 12 | "dommatrix": "^1.0.3", 13 | "pdfh5": "^2.0.2", 14 | "vue": "^3.2.13", 15 | "vuetify": "^3.0.0", 16 | "web-streams-polyfill": "^3.2.1" 17 | }, 18 | "devDependencies": { 19 | "@babel/core": "^7.12.16", 20 | "@babel/eslint-parser": "^7.12.16", 21 | "@vue/cli-plugin-babel": "~5.0.0", 22 | "@vue/cli-plugin-eslint": "~5.0.0", 23 | "@vue/cli-service": "~5.0.0", 24 | "eslint": "^7.32.0", 25 | "eslint-plugin-vue": "^8.0.3" 26 | }, 27 | "peerDependencies": { 28 | "worker-loader": "^3.0.8" 29 | }, 30 | "peerDependenciesMeta": { 31 | "worker-loader": { 32 | "optional": true 33 | } 34 | }, 35 | "browser": { 36 | "canvas": false, 37 | "fs": false, 38 | "http": false, 39 | "https": false, 40 | "url": false, 41 | "zlib": false 42 | }, 43 | "format": "amd", 44 | "eslintConfig": { 45 | "root": true, 46 | "env": { 47 | "node": true 48 | }, 49 | "extends": [ 50 | "plugin:vue/vue3-essential", 51 | "eslint:recommended" 52 | ], 53 | "parserOptions": { 54 | "parser": "@babel/eslint-parser" 55 | }, 56 | "rules": {} 57 | }, 58 | "browserslist": [ 59 | "> 1%", 60 | "last 2 versions", 61 | "not dead", 62 | "not ie 11" 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /example/vue3demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/vue3demo/public/favicon.ico -------------------------------------------------------------------------------- /example/vue3demo/public/git.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/vue3demo/public/git.pdf -------------------------------------------------------------------------------- /example/vue3demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /example/vue3demo/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | 17 | 18 | 43 | -------------------------------------------------------------------------------- /example/vue3demo/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/example/vue3demo/src/assets/logo.png -------------------------------------------------------------------------------- /example/vue3demo/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 41 | 42 | 43 | 59 | -------------------------------------------------------------------------------- /example/vue3demo/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | // Vuetify 4 | import 'vuetify/styles' 5 | import { createVuetify } from 'vuetify' 6 | import * as components from 'vuetify/components' 7 | import * as directives from 'vuetify/directives' 8 | 9 | const vuetify = createVuetify({ 10 | components, 11 | directives, 12 | }) 13 | createApp(App).use(vuetify).mount('#app') 14 | -------------------------------------------------------------------------------- /example/vue3demo/vue.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('@vue/cli-service'); 2 | module.exports = defineConfig({ 3 | transpileDependencies: true, 4 | configureWebpack: { 5 | resolve: { 6 | fallback: { 7 | "canvas": false, 8 | "fs": false, 9 | "http": false, 10 | "https": false, 11 | "url": false, 12 | "zlib": false 13 | } 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /git.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/git.pdf -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | pdf.js移动端展示预览打开pdf-pdfh5.js 12 | 13 | 14 | 149 | 150 | 151 | 152 |
153 |
154 |

pdfh5.js - 移动端预览PDF插件,基于pdf.js

155 | 157 |
158 |
159 | 163 | 167 | 168 |
169 |

pdfh5支持在线预览,修改地址栏file=后的地址就行,如果不填写,就在实例化的时候传入pdf地址:

170 | http://pdfh5.gjtool.cn/pdfh5/pdf.html?file=//pdfh5.gjtool.cn/pdfh5/test.pdf 172 |

173 | 默认优先获取浏览器地址栏?file=后面的地址,如果地址栏没有,再拿配置项的pdfurl或者data来渲染pdf。pdfh5实例初始化:

174 |
175 |     var pdfh5 = new Pdfh5(document.querySelector("#app"), {
176 |         pdfurl: 'test.pdf'
177 |     });
178 | 
179 |
180 | 181 |
182 | 184 | 187 |

鄂ICP备19002193号-1

189 |
190 | 191 |
192 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /js/pdfh5.worker.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/js/pdfh5.worker.js -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "pdfh5", 3 | "_id": "pdfh5@2.0.3", 4 | "_inBundle": false, 5 | "_integrity": "sha512-9I0AcoEdefvFJZqwv/1Q5ht4QGzmieoVqkd0uehp+62H0KrWtnXYfnHjlwQcfiStdynpCYYJu3A6F1AVUBbqbQ==", 6 | "_location": "/pdfh5", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "pdfh5", 12 | "name": "pdfh5", 13 | "escapedName": "pdfh5", 14 | "rawSpec": "", 15 | "saveSpec": null, 16 | "fetchSpec": "latest" 17 | }, 18 | "_requiredBy": [ 19 | "#USER", 20 | "/" 21 | ], 22 | "_resolved": "https://registry.npmjs.org/pdfh5/-/pdfh5-2.0.2.tgz", 23 | "_shasum": "c5e1a233c4baa346727bb968e7a68e2c3453b5aa", 24 | "_spec": "pdfh5", 25 | "_where": "/Users/gaojin/npm-pdfh5", 26 | "author": { 27 | "name": "Gao Jin" 28 | }, 29 | "bugs": { 30 | "url": "https://github.com/gjTool/pdfh5/issues" 31 | }, 32 | "bundleDependencies": false, 33 | "dependencies": {}, 34 | "deprecated": false, 35 | "description": " JS plugin of preview PDF for mobile. web/h5/移动端PDF预览手势缩放插件", 36 | "devDependencies": {}, 37 | "directories": { 38 | "example": "example" 39 | }, 40 | "homepage": "https://github.com/gjTool/pdfh5#readme", 41 | "keywords": [ 42 | "pdf", 43 | "pdf.js", 44 | "pdfjs", 45 | "pdfh5", 46 | "pdfh5.js", 47 | "javascript", 48 | "plugin", 49 | "library", 50 | "mobile" 51 | ], 52 | "license": "MIT", 53 | "main": "js/pdfh5.js", 54 | "name": "pdfh5", 55 | "repository": { 56 | "type": "git", 57 | "url": "git+https://github.com/gjTool/pdfh5.git" 58 | }, 59 | "scripts": {}, 60 | "version": "2.0.5" 61 | } -------------------------------------------------------------------------------- /pdf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | PDFH5 15 | 16 | 17 | 39 | 40 | 41 | 42 |
43 |
44 |
45 | 46 |
L
47 |
48 | 49 |
o
50 |
51 | 52 |
a
53 |
54 | 55 |
d
56 |
57 | 58 |
i
59 |
60 | 61 |
n
62 |
63 | 64 |
g
65 |
66 |
67 |
正在加载中,请您耐心等待...
68 |
69 | 70 |
71 |
72 | 73 | 74 | 75 | 76 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /pdfh5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/pdfh5.png -------------------------------------------------------------------------------- /test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gjTool/pdfh5/3fbcb03d4b911ba52502d4d432b0612dea64bd76/test.pdf --------------------------------------------------------------------------------