Skip to content

Instantly share code, notes, and snippets.

@dvnoble
Last active February 11, 2021 10:15
Show Gist options
  • Save dvnoble/54d095fa74a4f9aa4f1feab8a7cda5e6 to your computer and use it in GitHub Desktop.
Save dvnoble/54d095fa74a4f9aa4f1feab8a7cda5e6 to your computer and use it in GitHub Desktop.
Simple bash script to batch convert graphs descriptions (dot format) into a pdf. It requires graphviz.
#!/bin/bash
for GFILE in *.dot;
do
GNAME="${GFILE%.*}";
GTYPE=$(head -n 1 $GFILE);
case "$GTYPE" in
*digraph*) dot -Teps $GFILE -o "$GNAME.eps";;
*graph*) neato -Teps $GFILE -o "$GNAME.eps";;
esac
ps2pdf -dCompatibilityLevel=1.4 -dEmbedAllFonts=true -dSubsetFonts=true \
-dEPSCrop "$GNAME.eps" "$GNAME.pdf";
done
#rm *.eps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment