在 pom.xml
中已经内置了直接转出 PDF 的处理流程(为了平时的构建速度,默认是注释掉的)。但是,经过对比发现,使用 AsciiDoctor PDF 转出的 PDF,如果将 Asciidoctor Diagram 的图片格式设置为 PNG,那么图片模糊不清,放大以后还是看不清楚;如果设置为 SVG,则图片会多出一些不必要的线框。所以,推荐使用 HTML + wkhtmltopdf。流程如下:
-
使用上面“使用方法”中的办法,将文档转化成 HTML,然后启动 HTTP Server,确保可以在浏览器中通过 http://localhost:8888/target/docs/html/index.html 查看到文档内容。
-
使用如下命令,将文档转化成 PDF:
$ wkhtmltopdf --page-size A4 \ --header-left "[section]" \ --header-right "[subsection]" \ --header-spacing 3 \ --header-font-size 10 \ --footer-spacing 4 \ --footer-left "D瓜哥 · https://www.diguage.com" \ --footer-right '[page] / [toPage]' \ --footer-font-size 10 \ --margin-top 25mm \ --margin-bottom 25mm \ --margin-left 20mm \ --margin-right 20mm \ http://localhost:8888/target/docs/html/index.html 文档标题.pdf