Linux method for converting plain text documents into PDF files

  

There are a lot of software that can convert text files into PDF files. In Linux, you can convert text text into PDF without using software. Step, the following small series will introduce you to Linux to convert text files into PDF files.

Question: I want to convert a plain text file into a PDF document. Is there an easy way to convert a text file to a PDF file under the Linux command line?

When you have a bunch of text files to be maintained, convert them into PDF documents will be better. For example, PDF is more suitable for printing because PDF documents have a predefined layout. In addition to this, you can reduce the risk of accidental modification of your documents.

To convert a text file to PDF, you have to follow the two steps below.

Getting Ready

First you have to install two packages you need.

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

Converting text files to PDF

Once you're done, generate a PDF file from the text file in the following two steps.

First, use the enscript command-line tool to convert the text file to postscript format.

$ enscript -p output.ps input.txt

Finally convert the postscript format file to a PDF file.

$ ps2pdf output.ps output.pdf

The above is the introduction of Linux to convert text files into PDF. Here you need to use the command line tool, if you don't know the command line very well. Friends, you can also download related tools to convert.

Copyright © Windows knowledge All Rights Reserved