Linux下文本格式转pdf

在Linux系统中,将大量txt文档转换为便于阅读和保存的pdf格式是一种好方法。本文介绍了使用enscript和Ghostscript进行转换的步骤。首先通过enscript将txt转换为postscript格式,然后利用Ghostscript将postscript文件转化为pdf。
摘要由CSDN通过智能技术生成

在linux下编辑文档,txt格式的方便很多。如果有很多很大的txt文档,为了方便阅读和保存,转换为pdf格式的文件也是一种很不错的方法。

转载自:https://blog.csdn.net/fengzei886/article/details/41820655

1.工具介绍:

enscript:

https://www.gnu.org/software/enscript/
http://linuxcommand.org/man_pages/enscript1.html
 

是一个将文本文件(ASCII)转换为postscript,HTML,RTF的免费软件,可直接打印输出。

Ghostscript:

http://www.gnu.org/software/ghostscript/
可将postscript 语言解释成pdf格式。
 
2.工具安装:
 
在Debian, Ubuntu, Linux Mint上:
brandon@ubuntu:~/shell/Chapter1$ sudo apt-get install enscript ghostscript

在Fedora, Centos, RHEL上:

$sudo yum install enscript ghostscript

 

3.文件转换:

 

使用enscript将txt文本文件转换为postscript格式:

brandon@ubuntu:~/shell/Chapter1$ enscript -p sed_test.ps sed_test.txt

-p file命令是将enscript执行的结果导出到file文件,如果file替换为“-”,则将转换结果输出到标准输出。

 

使用postscript将转换后的文件再转换为pdf格式:

brandon@ubuntu:~/shell/Chapter1$ ps2pdf sed_test.ps sed_test.pdf
  1. brandon@ubuntu :~/shell/Chapter1$ ls
  2. sed_test.pdf sed_test.ps sed_test.txt
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值