Coder Perfect

[closed] CLI pdf viewer for Linux


Hello, I’ve been looking for a command-line PDF viewer for quite some time.

I’d like to have a tool to read pdfs because I prefer to work on Linux without X and frequently work on a remote system. There are a lot of great graphical tools for the purpose (evince, okular, acroread, etc. ), so I decided there should be at least one nice text-mode option. But I’m not even aware of a bad one!

Currently, I either use pdftohtml+lynx or start X only to read pdfs. The latter, on the other hand, does not yield very excellent results, and most manuscripts are unreadable, especially if they contain mathematical formulas.

People on Google are either stating it’s not doable or recommending the pdftohtml version.

I realize this isn’t strictly a programming question, but I’m thinking about starting a project to create such a program, unless there is already one available.

Thank you in advance for any suggestions.

Asked by bitmask

Solution #1

Hello, I believe you don’t need to develop a software to accomplish your goal of reading a pdf file in console mode because a few commands will suffice. So put it to good use and simply enjoy it.

less "the name of pdf file"

Answered by Kasra

Solution #2

You asked for the “worst” ones, so here they are. Here are two (you may judge for yourself how bad they are):

First, there’s the txtwrite output device in Ghostscript.

 gs \
   -dBATCH \
   -dNOPAUSE \
   -sDEVICE=txtwrite \
   -sOutputFile=- \

Second, the pdftotext CLI program from XPDF (which is superior to Ghostscript):

 pdftotext \
   -f 13 \
   -l 17 \
   -layout \
   -opw supersecret \
   -upw secret \
   -eol unix \
   -nopgbrk \
   - |less

This will display the pages 13 (first page) through 17 (final page) of a double-password protected named PDF file (with user and owner passwords secret and supersecret), using the Unix EOL convention, but without inserting pagebreaks between PDF pages, piped through less…

All available commandline arguments are displayed by pdftotext -h.

Both tools, of course, are limited to the text portions of PDFs (if they have any). Oh, and using a mathematical formula won’t work either… 😉

Correction: I had entered the command incorrectly above (originally using pdftops instead of pdftotext).

Answered by Kurt Pfeifle

Solution #3

There’s also the PDF viewer in green. On YouTube, there is a demonstration.

Answered by user287424

Solution #4

By the way, I’m constantly in the same scenario, and I use mc (midnight commander), which is really good at handling text pdf’s… Simply open the file in mc (F3) and view it.

Answered by mlwn

Solution #5

fbgs should be available from the fbi or fbida packages, depending on your distribution. It’s important to note that it only works in genuine terminals (ttys).

Answered by Giacomo

Post is based on