Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert text documents into PDF files under Linux

Shulou Source: shulou.com Published: 2022-06-01 15:30:02 10月03日 Update

This article will explain in detail how to convert text documents into PDF files under Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Now there are a lot of software that can convert text files into PDF files. In fact, in Linux systems, you can convert text into PDF without using software, just two easy steps.

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

Image-20211230214151308

When you have a lot of text files to maintain, it's better to convert them into PDF documents. For example, PDF is more suitable for printing because PDF documents have predefined layouts. In addition, you can reduce the risk that the document will be accidentally modified.

To convert a text file to PDF format, you need to follow the following two steps.

Preparatory work

First of all, you need to 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 converts text files to PDF format

After the preparation is complete, follow these two steps to generate a PDF file from the text file

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

$enscript-p output.ps input.txt

Finally, the postscript format file is converted into PDF file.

$ps2pdf output.ps output.pdf

On "how to convert text documents into PDF files under Linux" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Files text documents formatting articles commands more software face-to-face preparation work good practical unexpected no two content just pile tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi Huawei OPPO Reno Linux