Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么生成PDF版本? #392

Open
piazini opened this issue Jul 26, 2022 · 6 comments
Open

怎么生成PDF版本? #392

piazini opened this issue Jul 26, 2022 · 6 comments

Comments

@piazini
Copy link

piazini commented Jul 26, 2022

如题,怎么生成PDF版本?

@jaywcjlove
Copy link
Owner

@piazini 写个node JS 脚本批量生成PDF

@jaywcjlove
Copy link
Owner

@zjlovezj 单个页面生成 PDF?

@piazini
Copy link
Author

piazini commented Oct 25, 2022

@jaywcjlove 大佬,node JS脚本具体要怎么写? 网上搜索到的“Linux命令大全搜索工具 v1.8.0.pdf” 这个PDF是怎么制作的?

@jaywcjlove
Copy link
Owner

我不知道网上的那个怎么制作的,我可以给你提供一些思路

方法一

使用浏览器保存 PDF, command+p 打印预览,下面有打开预览 pdf,你就可以保存它,但是这种只能保存一个页面

image

方法二

nodejs 有多种方式生成 pdf,例如使用 markdown 生成 pdf 你可以自己控制样式 https://www.npmjs.com/package/markdown-pdf

var markdownpdf = require("markdown-pdf")

var options = {
    remarkable: {
        html: true,
        breaks: true,
        plugins: [ require('remarkable-classy') ],
		syntax: [ 'footnote', 'sup', 'sub' ]
    }
}

markdownpdf(options)
  .from("/path/to/document.md")
  .to("/path/to/document.pdf", function () { console.log("Done") })

在 npm 上有类似这样转换的包,html 转 pdf,所以你可以写nodejs 脚本干这个事儿。

@piazini
Copy link
Author

piazini commented Dec 12, 2022

非常感谢回答. 我用 Python 写了一个版本,可以自动将 md 生成 pdf

@wizardforcel
Copy link

我做了个 EPUB 格式的,大家可以转成 PDF:#510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants