Skip to content

Instantly share code, notes, and snippets.

@rozanecm
Last active May 24, 2020 04:28
Show Gist options
  • Save rozanecm/c75667b1c9bd54e2e41c3b0e39d6d253 to your computer and use it in GitHub Desktop.
Save rozanecm/c75667b1c9bd54e2e41c3b0e39d6d253 to your computer and use it in GitHub Desktop.
Make sure all lines are <80! This gist will generate pdfs for all .cpp and .h files in src/. A pdf per file will be stored in "print output/". All pdfs will be merged to one final file "final_print.pdf".
# print all .cpp and .h files
for f in $(find src/ -name '*.cpp' -or -name '*.h')
do
echo "Processing $f..."
a2ps --line-numbers=1 "$f" -o "$f".ps
done
mkdir "print output"
#for f in src/*.ps
for f in $(find src/ -name '*.ps')
do
b=$(basename $f)
ps2pdf "$f" "print output/${b%.*}.pdf"
rm "${f%.*}.ps"
done
cd 'print output'
pdfs=$(ls)
echo $pdfs
pdfunite $pdfs ../final_print.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment