Categories
How to's

How to view pdf file from console in linux

This article is about how to view a pdf file from linux console.
To view a pdf in a console install pdftohtml and elinks

$apt-get install pdftohtml elinks

then make a shell script

name it as pdfview
Here the script


#!/bin/sh
#Created by webmaster@http://linuxtuts.blogspot.com
NOARGS=0

if [ $# = $NOARGS ]
then
echo "usage :- pdfview filename.pdf"
exit
fi

if [ -d ~/tmp ]
then
echo "tmp directory exists hmmm....."
else
mkdir ~/tmp
fi

echo "converting pdf to html"
z=`expr substr "$*" 1 1`
#echo $z

if [ "$z" = "/" ]
then
file=$*
else

file=`pwd`/$*
fi

#echo "$file"
if ! [ -e "$file" ]
then
echo "File not found"
exit

fi

cd ~/tmp
pdftohtml -q "$file" temp.html

if [ -e ~/tmp/temp.html ]
then
echo "opening files"
elinks ~/tmp/temp.html
rm temp.html temps.html temp_ind.html
else

echo "The file cannot be converted"
exit
fi

echo "By http://linuxtuts.blogspot.com"

Then copy the file to /usr/local/bin
cd to directory /usr/local/bin
execute command as root
chmod a+x pdfview
and exit thats all.
Now u can view pdf files from console. You cannot view copyright material from this.

with command

$pdfview filename.pdf

to exit the application use q

Sample view