Enabling Chrome's PDF Viewer in Chromium on Linux

Here's a quick fix for something that was bugging me today in a fresh install of Xubuntu 13.04. Chromium does not install by default with a pdf viewer. Google Chrome, however, includes libpdf (a PDF reader library) by default. Below are instructions to rip this library out of a Google Chrome .deb package and install it in an existing Chromium install. The commands in this article are written for Debian based linux distributions.

To do all of this in one single action, run the command below and then open Chromium and visit about:plugins. You'll be prompted for your password once to copy the file to the correct location. This command just strings together all the commands necessary to install the library.

To see what each individual command does, see the descriptions after the break. 

wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && dpkg --fsys-tarfile google-chrome-stable_current_amd64.deb | tar -xf - ./opt/google/chrome/libpdf.so && sudo cp opt/google/chrome/libpdf.so /usr/lib/chromium-browser/ && rm -rf opt/ && rm google-chrome-stable_current_amd64.deb

Provided below is a step by step breakdown of what each command is doing:

First, you're going to need a copy of the latest Google Chrome release. This can be downloaded using the command:

wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
(or wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_i386.deb depending on your installation)

Next, you're going to want to extract the libpdf file from this .deb file. The location of the file you want to extract is opt/google/chrome/libpdf.so within the package. To pull out this file specifically, use the dpkg command with the --fsys-tarfile option, piped to the tar command, which reads from stdin and extracts the requested file. This command is seen below:

dpkg --fsys-tarfile google-chrome-stable_current_amd64.deb | tar -xf - ./opt/google/chrome/libpdf.so

Now, you need to take this file you just extracted and move it to the correct directory for Chromium to pick up when you open it. This, by default, is the /usr/lib/chromium-browser/ directory. To copy the file, run the command below:

sudo cp opt/google/chrome/libpdf.so /usr/lib/chromium-browser/

Finally, before you open Chromium to enable the plugin, clean up all the extra files from your current directory:

rm -rf opt/ && rm google-chrome-stable_current_amd64.deb

Now, the next time you open up Chromium type about:plugins in the address bar, and you should see Chrome PDF Viewer on the list.