From Predictive Chemistry
Jump to: navigation, search

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. =================== \1 ===================/;' | fold -w 80 -s >>tmp
 text2pdf  -f "Courier" -s 12 -o $name.pdf tmp

done rm -f tmp </source>