Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Enable PDF viewing in Chromium

0.00/5 (No votes)
13 Aug 2011CC (ASA 3U)2 min read 28K  
How to enable PDF viewing in Chromium

Prior to today, I had been using acroread to view PDF files in Chromium, which is embedded through MozPlugger and some tricks. However, it will open up a new window sometimes and it’s always slow. This article will enable PDF viewing in Chromium using two methods.

KParts Plugin

At first, I referenced this page and found the KParts Plugin.

I wget the source code tarball, uncompress it, and type cmake . in my terminal according to the README.txt. It checks for dependencies and reports an error “Qt qmake not found!

Type qmake directly in the terminal and it runs, so it is actually reachable buy CMake cannot find it. After some searches, I finally found this bug in Launchpad: “[Natty] CMake: FindQt4 doesn’t work if qt3-dev-tools are installed”.

The only work-around is to apt-get remove qt3-dev-tools.

cmake . again and I get another error reported saying “cmake/modules/FindKDE4Internal.cmake not found”. It is resolved in this post, which also provides some useful techniques like apt-file search.

After cmake . gets through, type make and sudo make install. KParts Plugin will be installed at /usr/lib/nsbrowser/plugins/ in my laptop. Then just:

$ sudo cp /usr/lib/nsbrowser/plugins/libkpartsplugin.so 
/usr/lib/chromium-browser/plugin/

Now you can view PDF files in Chromium and KParts Plugin works perfectly. However, there is always a bar on the top of the embedded Okular.

Chrome’s libpdf.so

Chrome has native support for PDF files, but it is not available officially in Chromium. You may wget one of the following packages, uncompress it, and find libpdf.so in opt/google/chrome/.

$ wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_i386.deb
$ wget https://dl-ssl.google.com/linux/direct/google-chrome-unstable_current_i386.deb
$ wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ wget https://dl-ssl.google.com/linux/direct/google-chrome-unstable_current_amd64.deb

On my laptop (Chromium 13.0.782.109, Ubuntu 11.04), I have to use package google-chrome-stable_current_i386.deb.

Then do something like:

$ cp /tmp/google-chrome-stable_current_i386/opt/
google/chrome/libpdf.so /usr/lib/chromium-browser/

You may have to try both the stable and the unstable releases and copy the file libpdf.so to your Chromium installation directory, and navigate to about:plugins to enable Chrome PDF Viewer.

Now you should get the PDF viewer working perfectly in Chromium, exactly the same as in Google Chrome.

License

This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License