Convert text file to pdf

To convert a text file into a PDF you can use enscript to convert it into a PostScript and pipe that through ps2pdf.

To get a txt2pdf command, add the following to your bash functions (in e.g. ~/.bash_function):

txt2pdf() {
  read -p "This will overwrite ${@%.*}.pdf. Are you sure? " -n 1 -r
  if [[ $REPLY =~ ^[Yy]$ ]]
    enscript "$@" --output=- | ps2pdf - > "${@%.*}".pdf

Last modified: 09/09/2014 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top