comparison_pdfs.sh 564 Bytes
Newer Older
1
#!/bin/bash
2
set -e
Phil Hughes's avatar
Phil Hughes committed
3 4 5
filename=$1
pdffilename=$2
pdffilename=${pdffilename/.html/.pdf}
6

Phil Hughes's avatar
Phil Hughes committed
7
echo "👉  Generating PDF for $filename..."
8

9 10 11 12 13
pdf_gen() {
  if [[ $1 -le 1 ]]
  then
    echo "❌ PDF $pdffilename was generated with errors!"
  else
Dan Gordon's avatar
Dan Gordon committed
14
    wkhtmltopdf --page-size Letter --margin-left 0 --margin-right 0 --margin-top 0 --javascript-delay 2000 $filename $pdffilename > pdf_gen_stderr.log 2>&1
15 16 17 18 19 20 21 22 23
    if grep "Warning" pdf_gen_stderr.log
    then
      echo "Retrying PDF generation"
      pdf_gen $1-1
    fi
  fi
}

pdf_gen 5
Phil Hughes's avatar
Phil Hughes committed
24 25

echo "✅  PDF $pdffilename generated!"