How to convert a text file to a PDF file in Linux
It is better to convert a large number of text files to PDF files for maintenance. For example, PDF is more suitable for printing because PDF documents have predefined la S. In addition, the document may be accidentally modified.
To convert a text file to a PDF file, follow the two steps below.
Preparations
First, install two required packages.
On Debian, Ubuntu, or Linux Mint:
$ Sudo apt-get install enscript ghostscript
On Fedora, CentOS/RHEL:
$ Sudo yum install enscript ghostscript
On Arch Linux:
$ Sudo pacman-S enscript ghostscript
Convert a text file to a PDF file
After the preparation is complete, generate a PDF file from the text file in the following two steps
First, use the enscript command line tool to convert a text file to a postscript format.
$ Enscript-p output. ps input.txt
Finally, convert a postscript file into a PDF file.
$ Ps2pdf output. ps output.pdf