Show pdf in ranger fm

Is there a way to make ranger scroll thru a pdf with several pages? With my settings (of ranger fm) show up just the first page of a pdf but i cannot scroll thru - eventual - further pages.

I’m using ranger + kitty

I don’t think this is possible, since ranger is just a file manager, not a pdf viewer/reader.

What you see in ranger - the first page of a pdf file (as long as you have configured it to work that way) - is only a preview, actually it’s an image created from the first page of the pdf file.

To view a pdf file and scroll through its pages, you’ll need a pdf reader/viewer.
If you’re into Vim-like keybindings, zathura is a very nice and simple pdf viewer.

2 Likes

I see … I hoped there was a way to make kitty a helper to do that (like for the image viewing (within ranger).

Yep, zathura is very smart - but unfortunately one one machine it won’t install correctly (not an arch one, but, psst :scream: a Mac) …

Rranger uses pdftotext to preview pdf files, but it can also work with pdftoppm. So by default it is a plain text file without any formatting. So it is not an image.

 cat ~/.config/ranger/scope.sh | grep pdf
        pdf)
            pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | \
        # application/pdf)
        #     pdftoppm -f 1 -l 1 \

You could fiddle with those settings

The preview shows the first 10 pages in plain text so set this number higher to be if you want more pages to be converted for preview. Mind pdftopmm shows 1 page by default but you can extent this also. Just uncheck pdftoppm and edit the numbers and don’f forget to check the pdftotext line(s) when you want pdftoppm to work.

When mouse scroll does not work (or you don’t want to use the mouse) in the preview window. Just push i to go into inspect mode and scroll with the arrow keys. Go back to normal mode with esc when your done

Thanks a lot, that’s interesting and i’ll try …

BUT: How could/would that prgrms deal with, e.g., scans saved to pdf?

As long it recognizes the text it would not matter. Else to be sure you could set it to pdftoppm which makes an image of the odf and shows it. It just takes more time and resources to do so, but with the right settings it will work.

Fine so far, thanks!

When i do

~ >>> cat ~/.config/ranger/scope.sh | grep pdf
    pdf)
        pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | \
      application/pdf)
         pdftoppm -f 1 -l 1 \

But the settings i found in my local scope.sh are this:

        ## PDF
    pdf)
        ## Preview as text conversion
        pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | \
          fmt -w "${PV_WIDTH}" && exit 5
        mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | \
          fmt -w "${PV_WIDTH}" && exit 5
        exiftool "${FILE_PATH}" && exit 5
        exit 1;;

And then:

        ## PDF
      application/pdf)
         pdftoppm -f 1 -l 1 \
                  -scale-to-x "${DEFAULT_SIZE%x*}" \
                  -scale-to-y -1 \
                  -singlefile \
                  -jpeg -tiffcompression jpeg \
                  -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
             && exit 6 || exit 1;;

But seems, something is broken, because i don’t get anymore all the images (some yes, other not, without any - obvious - reason; even some jpegs yes, some not, same for pngs

I checked all the settings, and as far as i understand (not so far probably) is all ok:

i have installed
pip install ranger-fm Pillow

in rc.conf i have: set preview_images true and set preview_images_method kitty

Any idea where i can check … (?)