Preview PDF as image in ranger

pdfranger

How can I preview PDFs as images in ranger? By default it uses pdftotext (in the scope.sh preview configuration file), but I would like to use pdfimages, pdftoppm, or another graphical solution instead.

The ArchWiki suggests a method using pdftoppm, but it appears out of date (it does not function as-is, and does not follow the structure of surrounding code).

Best Answer

This works in ranger-stable 1.8.1:

pdf)
        try pdftoppm -jpeg -singlefile "$path" "${cached//.jpg}" && exit 6 || exit 1;;

enter image description here

I also had to create ~/.cache/ranger on my system manually.

Related Question