gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
convert -colorspace RGB -interlace none -density 300x300 -quality 85 input.pdf output.jpg