Sunday, June 23, 2013

Print Preview and View PDF Files in Chromium on Ubuntu Server

Install Chromium:
$ sudo apt-get install chromium-browser

Now, launch Chromium, then navigate to

Click on the blue "Download" button. Depending on your architecture, select either "32-bit .deb" or "64-bit .deb". Move the .deb file to a build directory (things will get messy after you unpack it). After closing Chromium, run the following commands:
$ cd build
$ mkdir google-chrome
$ mv google-chrome-stable_current-amd64.deb google-chrome
$ cd google-chrome
$ ar vx *.deb
$ tar --lzma -xvf *.lzma

Look for a directory called "opt":
$ ls
$ cd opt/google/chrome

Copy all the *.so files into Chromium's directory in /lib:
$ ls
$ sudo cp -vr *.so /usr/lib/chromium-browser

Add the following to your $HOME/.bashrc or $HOME/.bash_aliases file:
alias chromium-browser='chromium-browser --enable-print-preview'

Launch Chromium. In the URL, type about:plugins. You should now see the Chrome PDF Viewer plugin (along with the others you copied over). Also, try printing a web page; you should be able to see a print preview of that page.


  1. Great tip, just what I was looking for !

    Just wanted to add that you can make have "--enable-print-preview" by default by updating the file /etc/chromium-browser/default and adding it to the variable CHROMIUM_FLAGS, such that:

    As I like to copy and paste commands from a setup doc for new Ubuntu installations, here is a block that could be copied and pasted in one go to perform the necessary download and customisation:

    ### Command to copy and paste start on line below:
    ( # Enclosing in subshell to preserve original directory x option
    if dpkg -l chromium-browser; then
    # Be verbose about what we are doing
    set -x

    # Create a temporary directory to work in
    mkdir ~/Downloads/google-chrome.$$ &&

    # Change to temporary work directory
    cd ~/Downloads/google-chrome.$$ &&

    # Grab the current stable version for the same architecture of chromium that is installed
    arch=$(dpkg -l chromium-browser | awk '$2=="chromium-browser" {print $4}') &&
    wget${arch:?}.deb &&

    # Extract the package
    ar vx *.deb &&

    # Extract just the libraries directly within ./opt/google/chrome/
    tar --lzma -xvf *.lzma --wildcards --no-wildcards-match-slash ./opt/google/chrome/*.so &&

    # Copy the extracted libraries to chromium's library directory
    cd opt/google/chrome &&
    sudo cp -vr *.so /usr/lib/chromium-browser &&

    # Add --enable-print-preview as a default chromium flag if not already added
    sudo perl -pi.old -e 's/(CHROMIUM_FLAGS=\"(?!--enable-print-preview))/$1--enable-print-preview/' /etc/chromium-browser/default &&

    # Remove the temporary working directory
    cd &&
    rm -r ~/Downloads/google-chrome.$$
    ### Command to copy and paste ends on line above

    1. Glad I was able to help you with my post. Thank you for posting your terrific solution! This is something I can certainly use in one of my future Chrome or Chromium installations.