Skip to content

Instantly share code, notes, and snippets.

@even4void
Created January 11, 2022 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save even4void/c301baf74a372cb8fc761769bdd14c30 to your computer and use it in GitHub Desktop.
Save even4void/c301baf74a372cb8fc761769bdd14c30 to your computer and use it in GitHub Desktop.
Convert page from a PDF to a PNG
#!/usr/bin/env bash
# Note: pdftoppm has page range so the first line is probably not necessary.
f="/tmp/tmp.$RANDOM"
pdftk "$1" cat $2 output $f
pdfcrop $f $f.crop
pdftoppm -png -rx 300 -ry 300 $f.crop $HOME/"$1".png
rm $f $f.crop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment