Friday, September 24, 2010

Using evince (or acrobat reader) to read pdf in your web browser

I use google chrome so when I open pdf files, it usually opens in Google doc.
But when I try to open pdf file that is stored on my computer. (i.e. my lecture notes) through my web browser, it gets downloaded. It's not a big deal, but every seconds of my life is precious. So here is the fix that will allow you to open pdf embedded in your web browser. I tested this on my Google chrome, but I believe it will also work on firefox.

1. sudo apt-get install mozplugger
2. sudo gedit /etc/mozpluggerrc
3. Add following line:
repeat noisy needs_xembed swallow(evince) fill: evince "$file"
below these lines:
text/pdf:pdf:PDF file
text/x-pdf:pdf:PDF file

Mine looks like this:
application/pdf:pdf:PDF file
application/x-pdf:pdf:PDF file
text/pdf:pdf:PDF file
text/x-pdf:pdf:PDF file
repeat noisy needs_xembed swallow(evince) fill: evince "$file"
repeat noisy swallow(kpdf) fill: kpdf "$file"
repeat noisy swallow(Xpdf) fill: xpdf -g +9000+9000 "$file"
repeat noisy swallow(okular) fill: okular "$file"
repeat noisy fill exits: evince "$file"

Note: in web browser, evince won't let you go through pages with Page Up or Down. And if the size of pdf file comes out to be like thumbnail size. Just press F5 to refresh and the evince will render fine.

If you like to use acrobat reader instead, skip step 3 and have acrobat reader installed. But evince will definitely use less resources.