Skip to content

Instantly share code, notes, and snippets.

@ongardie
Created December 12, 2014 21:31
Show Gist options
  • Save ongardie/ab236df4f61abcaff60c to your computer and use it in GitHub Desktop.
Save ongardie/ab236df4f61abcaff60c to your computer and use it in GitHub Desktop.
txt2pdf: convert plaintext to PDF
#!/bin/sh
# Convert plaintext to PDF
if [ $# -eq 2 ]
then
outfile=$2
elif [ $# -eq 1 ]
then
outfile=`basename "$1" \.txt`.pdf
else
echo "Usage: `basename \"$0\"` input.txt [output.pdf]" 1>&2
exit 1
fi
exec enscript --quiet --title="$(head -n1 $1)" --margins=60:60:60:60 --no-header --output=- $1 | ps2pdf - >$outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment