├── bin ├── pdf-a4-landscape.bat ├── pdf-a4-portrait.bat ├── pdf-a5-landscape.bat ├── pdf-a5-portrait.bat ├── html2pdf.bat ├── pdf-a4-landscape ├── pdf-a4-portrait ├── pdf-a5-landscape ├── pdf-a5-portrait ├── pdf-print ├── pdf-print.bat └── html2pdf ├── dist ├── cover.jpg ├── img │ └── 1.png ├── static │ ├── img │ │ └── nop.jpg │ └── js │ │ └── qrcode-generator │ │ └── 1.4.4 │ │ └── qrcode.min.js ├── data │ ├── chart-2.json │ └── chart-1.json ├── eazy-3.html ├── eazy-4.html ├── eazy-2.html ├── eazy-6.html └── eazy-1.html ├── qq-group-1.png ├── .gitignore ├── eazy-2-qrcode.png ├── simple-4-qrcode.png ├── converter ├── wkhtml2pdf │ ├── wkhtmltopdf-webkit-suport.pdf │ └── modernizr.html ├── puppeteer │ └── index.js └── chrome-headless │ └── index.js ├── docker-stop.bat ├── docker-stop.sh ├── .editorconfig ├── package.json ├── docker-start.bat ├── docker-start.sh ├── wslpath.bat ├── LICENSE ├── BookJsHelper.md ├── .gitattributes ├── README.md └── README-en.md /bin/pdf-a4-landscape.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | "%~pd0\pdf-print.bat" A4 Landscape %* 4 | -------------------------------------------------------------------------------- /bin/pdf-a4-portrait.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | "%~pd0\pdf-print.bat" A4 Portrait %* 4 | -------------------------------------------------------------------------------- /bin/pdf-a5-landscape.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | "%~pd0\pdf-print.bat" A5 Landscape %* 4 | -------------------------------------------------------------------------------- /bin/pdf-a5-portrait.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | "%~pd0\pdf-print.bat" A5 Portrait %* 4 | -------------------------------------------------------------------------------- /dist/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/dist/cover.jpg -------------------------------------------------------------------------------- /dist/img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/dist/img/1.png -------------------------------------------------------------------------------- /qq-group-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/qq-group-1.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /yarn.lock 2 | /package-lock.json 3 | /node_modules 4 | /.idea 5 | /dist/pdf 6 | -------------------------------------------------------------------------------- /eazy-2-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/eazy-2-qrcode.png -------------------------------------------------------------------------------- /simple-4-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/simple-4-qrcode.png -------------------------------------------------------------------------------- /bin/html2pdf.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SCRIPT_PATH=%~dp0 4 | node "%SCRIPT_PATH%\html2pdf" %* 5 | -------------------------------------------------------------------------------- /dist/static/img/nop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/dist/static/img/nop.jpg -------------------------------------------------------------------------------- /bin/pdf-a4-landscape: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | script_path=$(cd `dirname "$0"`;pwd) 4 | "${script_path}/pdf-print" A4 Landscape $@ 5 | -------------------------------------------------------------------------------- /bin/pdf-a4-portrait: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | script_path=$(cd `dirname "$0"`;pwd) 4 | "${script_path}/pdf-print" A4 Portrait $@ 5 | -------------------------------------------------------------------------------- /bin/pdf-a5-landscape: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | script_path=$(cd `dirname "$0"`;pwd) 4 | "${script_path}/pdf-print" A5 Landscape $@ 5 | -------------------------------------------------------------------------------- /bin/pdf-a5-portrait: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | script_path=$(cd `dirname "$0"`;pwd) 4 | "${script_path}/pdf-print" A5 Portrait $@ 5 | -------------------------------------------------------------------------------- /converter/wkhtml2pdf/wkhtmltopdf-webkit-suport.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxue107/bookjs-eazy/HEAD/converter/wkhtml2pdf/wkhtmltopdf-webkit-suport.pdf -------------------------------------------------------------------------------- /docker-stop.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SCRIPT_PATH=%~dp0 4 | cd %SCRIPT_PATH% 5 | 6 | 7 | echo docker stop screenshot-api-server 8 | docker stop screenshot-api-server 9 | -------------------------------------------------------------------------------- /docker-stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_PATH=$(cd `dirname "$0"`;pwd) 4 | cd "${SCRIPT_PATH}"; 5 | 6 | 7 | echo docker stop screenshot-api-server 8 | docker stop screenshot-api-server 9 | # docker rm screenshot-api-server 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = false 10 | [*.bat] 11 | end_of_line = crlf 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.{yml,yaml}] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /converter/wkhtml2pdf/modernizr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |10 | 11 |12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bookjs-eazy", 3 | "version": "1.17.0", 4 | "main": "index.js", 5 | "repository": "https://gitee.com/wuxue107/bookjs-eazy.git", 6 | "author": "nop <575065955@qq.com>", 7 | "license": "MIT", 8 | "bin": { 9 | "html2pdf": "bin/html2pdf" 10 | }, 11 | "scripts": { 12 | }, 13 | "files": [ 14 | "dist" 15 | ], 16 | "devDependencies": { 17 | }, 18 | "dependencies": { 19 | "chrome-remote-interface": "^0.28.2", 20 | "commander": "<12", 21 | "puppeteer": "^5.5.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /bin/pdf-print: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | PAGE_SIZE=$1 5 | ORIENTATION=$2 6 | URL=$3 7 | OUTPUT=$4 8 | 9 | [ "${PAGE_SIZE}" == "" ] && PAGE_SIZE=A4 10 | [ "${ORIENTATION}" != "Landscape" ] && ORIENTATION=Portrait 11 | [ "${OUTPUT}" == "" ] && OUTPUT=output.pdf 12 | 13 | wkhtmltopdf --window-status "PDFComplete" \ 14 | --disable-smart-shrinking \ 15 | --margin-left 0 --margin-right 0 --margin-top 0 --margin-bottom 0 --page-size "${PAGE_SIZE}" \ 16 | --orientation "${ORIENTATION}" \ 17 | --no-stop-slow-scripts \ 18 | --enable-internal-links \ 19 | --debug-javascript \ 20 | --print-media-type \ 21 | --outline --outline-depth 3 \ 22 | --log-level info \ 23 | "${URL}" "${OUTPUT}" 24 | -------------------------------------------------------------------------------- /docker-start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SCRIPT_PATH=%~dp0 4 | cd %SCRIPT_PATH% 5 | 6 | set WEB_PORT=%1 7 | set IMAGE_TAG=%2 8 | 9 | IF "%IMAGE_TAG%" == "" set IMAGE_TAG=latest 10 | IF "%WEB_PORT%" == "" set WEB_PORT=3000 11 | 12 | call wslpath.bat "dist" WEB_PATH 2>NUL 13 | 14 | echo docker run --cpus="0.7" -p %WEB_PORT%:3000 -td --rm -v "%WEB_PATH%:/screenshot-api-server/public" --name=screenshot-api-server wuxue107/screenshot-api-server:%IMAGE_TAG% 15 | docker run --cpus="0.7" -p %WEB_PORT%:3000 -td --rm -v "%WEB_PATH%:/screenshot-api-server/public" --name=screenshot-api-server wuxue107/screenshot-api-server:%IMAGE_TAG% 16 | 17 | echo LISTEN : %WEB_PORT% 18 | echo WEB_ROOT : %WEB_PATH% 19 | -------------------------------------------------------------------------------- /bin/pdf-print.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set URL=%3 4 | set URL=%URL:&=^&% 5 | set FILE=%4 6 | set PAGE_SIZE=%1 7 | set ORIENTATION=%2 8 | 9 | IF "%FILE%" == "" SET FILE=output.pdf 10 | IF "%PAGE_SIZE%" == "" SET PAGE_SIZE=A4 11 | IF NOT "%ORIENTATION%" == "Landscape" SET ORIENTATION=Portrait 12 | 13 | wkhtmltopdf --window-status "PDFComplete" ^ 14 | --disable-smart-shrinking ^ 15 | --margin-left 0 --margin-right 0 --margin-top 0 --margin-bottom 0 ^ 16 | --no-stop-slow-scripts ^ 17 | --enable-internal-links ^ 18 | --debug-javascript ^ 19 | --print-media-type ^ 20 | --outline --outline-depth 3 ^ 21 | --log-level info ^ 22 | --page-size %PAGE_SIZE% ^ 23 | --orientation %ORIENTATION% ^ 24 | %URL% %FILE% 25 | -------------------------------------------------------------------------------- /docker-start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_PATH=$(cd `dirname "$0"`;pwd) 4 | cd "${SCRIPT_PATH}"; 5 | 6 | WEB_PORT=$1 7 | IMAGE_TAG=$2 8 | [ "${IMAGE_TAG}" == "" ] && IMAGE_TAG=latest 9 | [ "${WEB_PORT}" == "" ] && WEB_PORT=3000 10 | 11 | WEB_PATH=${PWD}/dist 12 | [ -d "${WEB_PATH}" ] || mkdir "${WEB_PATH}" 13 | 14 | echo docker run --cpus="0.7" -p ${WEB_PORT}:3000 -td --rm -v ${WEB_PATH}:/screenshot-api-server/public --name=screenshot-api-server wuxue107/screenshot-api-server:${IMAGE_TAG} 15 | docker run --cpus="0.7" -p ${WEB_PORT}:3000 -td --rm -v ${WEB_PATH}:/screenshot-api-server/public --name=screenshot-api-server wuxue107/screenshot-api-server:${IMAGE_TAG} 16 | 17 | echo LISTEN : ${WEB_PORT} 18 | echo WEB_ROOT : ${WEB_PATH} 19 | -------------------------------------------------------------------------------- /wslpath.bat: -------------------------------------------------------------------------------- 1 | 2 | :: 取个怪异的名字加"__",尽量不干扰全局的变量 3 | :: 使用方式: call wslpath.bat [WINDOW路径] [保存的变量名] 4 | :: call wslpath.bat . MOUNT_PATH 5 | :: call wslpath.bat "C:\Program Files\Docker" MOUNT_PATH 6 | :: 7 | :: MIT License 8 | :: @https://gitee.com/wuxue107/wslpath.bat 9 | :: 10 | :: SETLOCAL 11 | 12 | set __SET_PARAM_NAME=%2 13 | set __FULL_PATH=%~f1 14 | set __FILE_PATH=%__FULL_PATH:~2% 15 | set __FILE_PATH=%__FILE_PATH:\=/% 16 | set __DEVICE_NAME=%~d1 17 | set __DEVICE_NAME=%__DEVICE_NAME::=% 18 | 19 | for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call set __DEVICE_NAME=%%__DEVICE_NAME:%%i=%%i%% 20 | :: ENDLOCAL 21 | if "%__SET_PARAM_NAME%" == "" ( 22 | echo /%__DEVICE_NAME%%__FILE_PATH% 23 | ) else ( 24 | set %__SET_PARAM_NAME%=/%__DEVICE_NAME%%__FILE_PATH% 25 | ) 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 wuxue107 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 | -------------------------------------------------------------------------------- /BookJsHelper.md: -------------------------------------------------------------------------------- 1 | # BookJsHelper 辅助函数说明 2 | 3 | 4 | ## BookJsHelper.getQueryParam(queryParamName, defaultValue, url) 获取页面Query参数 5 | ```javascript 6 | // 当前页: /eazy-1.html?aa=11&bb=22 7 | ret = BookJsHelper.getQueryParam() 8 | //ret => {aa:'11',bb:'22'} 9 | ret = BookJsHelper.getQueryParam('cc','33') 10 | //ret => '33' 11 | ret = BookJsHelper.getQueryParam('dd','444','/some?dd=44') 12 | //ret => 44 13 | ``` 14 | 15 | ## BookJsHelper.showMsg(msg) 显示一个弹出层消息,返回msgId 16 | ```javascript 17 | ret = BookJsHelper.showMsg(msg) 18 | // ret => 'id-xxxxxx' 消息ID 19 | ``` 20 | ### BookJsHelper.closeMsg(msgId) 根据msgId关闭弹出层消息 21 | 22 | 23 | ### BookJsHelper.closeAllMsg() 关闭所有弹出层消息 24 | 25 | ### BookJsHelper.isMobile() 返回当前是否为在手机端浏览 26 | ### BookJsHelper.isWkHtmlToPdf() 返回当前浏览器是否为wkhtmltopdf内核 27 | ### BookJsHelper.isHeadless() 返回当前是否无头浏览器模式下浏览 28 | 29 | ### BookJsHelper.tag(tagName,attrs,content) 构建html片段 30 | - tagName: 标签名 31 | - attrs : String/Object 属性 32 | - content : String/Array 内容 33 | ```javascript 34 | ret = BookJsHelper.tag( 35 | 'select', 36 | {class:'form-control',name:'type',data:{aa:1,bb:2}}, 37 | [ 38 | ['option',{value:"2"},"选项2"], 39 | ['option',{value:"1"},"选项1"], 40 | ] 41 | ); 42 | 43 | 44 | // ret => 45 | 46 | ``` 47 | 48 | ### BookJsHelper.dataPath(path,sourceData,defaultValue) 从多层级数据中取值,不存在的返回默认值 49 | ```javascript 50 | data = {a1:{a2:111},b1:[{b2:222}]}; 51 | 52 | // BookJsHelper.dataPath('a1.a2',data) => 111 53 | // BookJsHelper.dataPath('a1.a2.a3',data) => null 54 | // BookJsHelper.dataPath('a1.a2.a3',data,123) => 123 55 | // BookJsHelper.dataPath('b1[0].b2',data) => 222 56 | 57 | ``` 58 | -------------------------------------------------------------------------------- /bin/html2pdf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // apt install chromium-browser 3 | // docker run -d -p 9222:9222 --rm --name headless-shell chromedp/headless-shell 4 | // "C:\Program Files\Google\Chrome\Application\chrome.exe" --headless --disable-gpu --remote-debugging-port=9222 --disable-extensions --mute-audio 5 | // "chromium-browser" --headless --disable-gpu --remote-debugging-port=9222 --disable-extensions --mute-audio 6 | // "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless --disable-gpu --remote-debugging-port=9222 7 | 8 | // node bin/html2pdf print --agent=puppeteer --checkJs "window.status === 'PDFComplete'" --output simple-4.pdf --timeout 60000 --printDelay 1000 "https://bookjs.zhouwuxue.com/simple-4.html" 9 | 10 | const program = require('commander'); 11 | program.version('1.0.0') 12 | .command('print
Hello World!
247 |long text...
276 |long text2...
277 | ``` 278 | 279 | - 使用在符合下列选择器规则的位置之一: 280 | ``` 281 | #content-box> 下的一级节点 282 | [data-op-type=mix-box] .nop-fill-box> 混合盒子容器节点下的一级节点 283 | [data-op-type=table] tbody td> 表格的单元格的一级节点 284 | ``` 285 | 286 | 287 | ### new-page: 新页,手动控制添加新页 288 | - 在标记的节点后的内容,将从新的一页开始写入 289 | - 例如:[新页示例](https://bookjs.zhouwuxue.com/static/book-tpl/editor.html?code=R992XN88) 290 | ```html 291 || 生物种类 | 363 |子类别 | 364 |详解介绍 | 365 |
| 动物 | 370 |爬行动物 | 371 |
372 | long text1 ...
373 | long text2 ... 375 |...
376 | |
377 |
| 哺乳动物 | 380 |
381 | long text1 ... 382 |long text2 ... 384 |...
385 | |
386 | |
| 植物 | 389 |蕨类 | 390 |
391 | long text... 392 | |
393 |
| ID | name |
|---|---|
| 1 | name1 |
| 2 | name2 |
| ... | ... |
Hello World!
248 |long text...
277 |long text2...
278 | ``` 279 | 280 | - Use in one of the positions that meet the following selector rules: 281 | ``` 282 | #content-box> next level node 283 | [data-op-type = mix-box] .nop-fill-box> Level 1 node under the mixed box container node 284 | [data-op-type = table] tbody td> The first-level node of the cell of the table 285 | ``` 286 | 287 | 288 | ### new-page: new page, manual control to add new page 289 | - The content after the marked node will be written starting from the new 1 page 290 | - Example: [New Page Example](https://bookjs.zhouwuxue.com/static/book-tpl/editor.html?code=R992XN88) 291 | ```html 292 || Biological species | 364 |Subcategories | 365 |Detailed introduction | 366 |
| Animals | 371 |Reptile | 372 |
373 | long text1 ...
374 | long text2 ... 376 |...
377 | |
378 |
| Mammals | 381 |
382 | long text1 ... 383 |long text2 ... 385 |...
386 | |
387 | |
| Plants | 390 |Ferns | 391 |
392 | long text... 393 | |
394 |
| ID | name |
|---|---|
| 1 | name1 |
| 2 | name2 |
| ... | ... |