Command-Line – Print a Regular File to PDF

command linepdfvirtual-printer

In gedit, printing a file gives an option of printing to file where the file can be saved as a pdf. How can I do the same thing from the command line?

Best Answer

Here's a solution that doesn't involve OpenOffice:

  1. sudo apt-get install enscript

  2. enscript my_text_file.txt -o - | ps2pdf - output.pdf

There are more options to enscript, e.g. -B to omit the page header. See man enscript for all of the options.

Related Question