参考了其他网页内容,网页上说:
输出为PDF文件,需要先安装gitbook pdf
$ npm install gitbook-pdf -g
如果在安装gitbook-pdf时,觉得下载
phantomjs
包太慢的话,你可以到phantomjs
的官方网站上去下载。这个包的安装方式,参考其官网的说明文档。
然后,用下面的命令就可以生成PDF文件了。
$ gitbook pdf {book_name}
如果,你已经在编写的gitbook当前目录,也可以使用相对路径。
$ gitbook pdf .
然后,你就会发现,你的目录中多了一个名为book.pdf
的文件。
我是这么干的
1 [root@fedora phantomjs]# npm install gitbook-pdf -registry https://registry.npmmirror.com 2 3 npm WARN deprecated eslint@1.10.3: This version is no longer supported. Please see https://eslint.org/version-support for other options. 4 npm ERR! code 1 5 npm ERR! path /root/node_modules/.store/phantomjs@2.1.7/node_modules/phantomjs/node_modules/phantomjs 6 npm ERR! command failed 7 npm ERR! command sh -c -- node install.js 8 npm ERR! Downloading http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 9 npm ERR! Saving to /tmp/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2 10 npm ERR! Receiving... 11 npm ERR! Error requesting archive. 12 npm ERR! Status: 301 13 npm ERR! Request options: { 14 npm ERR! "protocol": "http:", 15 npm ERR! "slashes": true, 16 npm ERR! "auth": null, 17 npm ERR! "host": "cdn.bitbucket.org", 18 npm ERR! "port": null, 19 npm ERR! "hostname": "cdn.bitbucket.org", 20 npm ERR! "hash": null, 21 npm ERR! "search": null, 22 npm ERR! "query": null, 23 npm ERR! "pathname": "/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2", 24 npm ERR! "path": "/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2", 25 npm ERR! "href": "http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2" 26 npm ERR! } 27 npm ERR! Response headers: { 28 ...
第8行有需要下载的软件包和url,后来显示的是说未下载成功。现在手动下载该包,并移动到/tmp/phantomjs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root@fedora ~] # npm install gitbook-pdf -registry https://registry.npmmirror.com npm WARN deprecated osenv@0.0.3: This package is no longer supported. npm WARN deprecated ini@1.1.0: Please update to ini >=1.3.6 to avoid a prototype pollution issue npm WARN deprecated rimraf@2.2.8: Rimraf versions prior to v4 are no longer supported npm WARN deprecated npmconf@0.0.24: this package has been reintegrated into npm and is now out of date with respect to npm npm WARN deprecated mkdirp@0.3.5: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has change d to use Promises in 1.x.) npm WARN deprecated mkdirp@0.3.5: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has change d to use Promises in 1.x.) added 17 packages, and changed 1 package in 4s 2 packages are looking for funding run `npm fund` for details |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)