CLI pdf viewer for linux

LinuxPdfCommand LineNcursesPdftotext

Linux Problem Overview


Hey, for quite a while now, I am looking for a pdf viewer for the command line.

As I like to work without X on Linux, and often work on a remote machine, I would like to have a tool to read pdfs. There are quite a lot of really good graphical programs (evince, okular, acroread, ...) to do the job, so I figured there should be at least one decent text-mode tool. But I don't even know of a crappy one!

Currently, I either start X only to read pdfs, or use pdftohtml+lynx. However, the latter does not produce a very good output, and most documents are just unreadable, especially if they contain mathematical formula.

Google is full of people saying either it's not possible or suggesting the pdftohtml version.

I realise, this is not exactly a programming question, but I am currently considering starting a project to implement such a program, unless there already is a good one out there.

Thanks for any suggestions.

Linux Solutions


Solution 1 - Linux

Hi I think that you don't need to write a program for your purpose I mean reading pdf file in console mode because less command already do it for you. So use it and just enjoy it.

less "the name of pdf file"

Solution 2 - Linux

Ok, you asked to know even "crappy" ones. Here are two (decide yourself about their respective crappiness):

First: Ghostscript's txtwrite output device

 gs \
   -dBATCH \
   -dNOPAUSE \
   -sDEVICE=txtwrite \
   -sOutputFile=- \
   /path/to/your/pdf

Second: XPDF's pdftotext CLI utility (better than Ghostscript):

 pdftotext \
   -f 13 \
   -l 17 \
   -layout \
   -opw supersecret \
   -upw secret \
   -eol unix \
   -nopgbrk \
   /path/to/your/pdf
   - |less

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

pdftotext -h displays all available commandline options.

Of course, both tools only work for the text parts of PDFs (if they have any). Oh, and mathematical formula also won't work too well... ;-)


Edit: I had mis-typed the command above (originally using pdftops instead of pdftotext).

Solution 3 - Linux

Solution 4 - Linux

There is also the green PDF viewer. There is a demo on YouTube.

Solution 5 - Linux

By the way, i m always in the same situation, and I use mc (midnight commander) which handles text pdf's very well... Just view the file (F3) in mc

Solution 6 - Linux

fbpdf is a framebuffer pdf viewer.

There is also a fork, jfbpdf, but at the moment I am not able to get it working.

Solution 7 - Linux

This would only work if your PDF document is structured, i.e. it is a tagged PDF document.

This is required to get the correct reading-order of the text objects in the document.

Tagged PDF documents also allow your to re-flow the document though I am not aware of any tool doing that with command line output.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbitmaskView Question on Stackoverflow
Solution 1 - LinuxKasraView Answer on Stackoverflow
Solution 2 - LinuxKurt PfeifleView Answer on Stackoverflow
Solution 3 - LinuxGiacomoView Answer on Stackoverflow
Solution 4 - Linuxuser287424View Answer on Stackoverflow
Solution 5 - LinuxmlwnView Answer on Stackoverflow
Solution 6 - Linuxuser3714903View Answer on Stackoverflow
Solution 7 - LinuxDirk VollmarView Answer on Stackoverflow