Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux how to convert plain text documents into PDF files without using software

Shulou Source: shulou.com Published: 2022-06-01 08:00:54 10月01日 Update

This article introduces Linux how to convert plain text documents into PDF files without using software, the content is very detailed, interested friends can refer to it, hope to be helpful to you.

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?

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

Convert a text file 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

About Linux does not need to use software how to convert plain text documents into PDF files to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Files text documents formatting no software content commands more face-to-face preparation work help good unexpected two interests piles boys buddies Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information Shulou Tech Info Redmi MySQL