2022年7月

背景

org 直接导出的 html 文件,需要转化为 pdf,才能方便大家浏览。

解决方法

结果网上搜索之后,找到 wkhtmltopdf 这个工具,经过尝试之后,使用的时候,是有一些注意点的。

ubuntu

ubuntu 下面可以直接使用 apt 安装,但是安装后的,只能使用默认选项,其他的很多参数是无效的,提示 qt 的问题。

win

  • windows 下面直接下载 7z 格式的,安装后,使用报错。
  • 去 github 上面下载 0.13.2 的版本,这个版本支持 目录等很多功能,新版反而不支持了。 https://github.com/wkhtmltopdf/wkhtmltopdf/releases/0.12.3.2/

增加专门的目录页

使用 toc --toc-header-text "目录",这样就可以生成专门的目录页。 例如:

.\wkhtmltopdf.exe toc --toc-header-text "目录" C:\Users\Administrator\Downloads\before_tooling_with_production_department.html be.pdf

org 增加标题和中文目录,去除页尾的签名

#+TITLE: 标题
#+LANGUAGE: zh-CN
#+OPTIONS: html-postamble:nil

如果不说明是中文,那么目录栏显示的就是 “Table of Contents”

参考:

Org-mode 导出 html 模版设置
https://bnlt.org/2019/Org-Mode%E5%AF%BC%E5%87%BAhtml%E6%A8%A1%E7%89%88%E8%AE%BE%E7%BD%AE/

使用 wkhtmltopdf 将网页生成 带有 封面 、 目录、水印的pdf
https://www.jianshu.com/p/1a0fb28e6bec

html超链接点不了_HTML 转 PDF 之 wkhtmltopdf 工具精讲
https://blog.csdn.net/weixin_31098573/article/details/112516783

wkhtmltopdf
https://wkhtmltopdf.org/downloads.html