Getting started with Linux: how to convert text files to PDF files in Linux
Question: I want to convert a plain text file into a PDF file. Is there a simple way to convert a text file into a PDF file under the Linux Command Line?
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
How to Use LibreOffice to convert docx, DOC, RTF, and ODT to PDF
This article permanently updates the link address: