linux C 生成带有格式的文件 wkhtmltopdf(类似word的效果 有颜色 字体等等)

来源:互联网 发布:淘宝怎么买砍刀 编辑:程序博客网 时间:2024/06/03 16:08

一般来说我们直接往文件里写东西 是没法带有格式的

因此我们需要借助html

将要写的东西,以html的形式写好,自然就可以带有格式了

之后将这个html文件转换为pdf文件即可。

html文件转换为pdf文件时,我们可以借助开源工具 wkhtmltox(wkhtmltopdf),效果非常好。


再说一句题外话,将txt之类的文本文档如何转换为pdf呢?我们可以使用工具ghostscript、enscript。

#!/bin/shtouch TESTtar -zxvf ghostscript-9.15-linux-x86_64.tgzcd ghostscript-9.15-linux-x86_64mv gs-915-linux_x86_64 gscp gs /usr/bin/tar -zxvf enscript-1.6.4.tar.gzcd enscript-1.6.4./configure --prefix=/usr/local/enscript/makemake installcp /usr/local/enscript/bin/enscript /usr/bin/enscript -p TEST.ps TESTps2pdf TEST.ps TEST.pdf


完!!

阅读全文
0 0