Code:text2pdf
From Predictive Chemistry
Revision as of 08:05, 15 September 2014 by David M. Rogers (talk | contribs) (Created page with "Here's a small shell script that uses the '''text2pdf''' utility (along with standard tr, sed, and fold utils) to create pdf documents from text file inputs. Note the ^==*, whic…")
Here's a small shell script that uses the text2pdf utility (along with standard tr, sed, and fold utils) to create pdf documents from text file inputs. Note the ^==*, which turns lines starting with = Name into clearly delimited sections. Tr and sed remove dos formatting and remove extra blank lines.
<source lang="bash"> for i in *.txt; do
name=`basename $i .txt` [ -s $name.pdf ] && continue echo $i >tmp cat $i | tr -d '\r' | sed -e '/^ *$/d; s/^==*\(.*\)/\
\ \ \ \
- =================== \1 ===================/;' | fold -w 80 -s >>tmp
text2pdf -f "Courier" -s 12 -o $name.pdf tmp
done rm -f tmp </source>