How to install poppler >= 0.73 on ubuntu 20.04 (any change since 18.04?)

I have seen the first answer to How to install poppler 0.73 on ubuntu 18.04 which basically consists of the following steps:

Compile and install Poppler 0.73 with checkinstall to the /usr/local:

sudo apt-get install libopenjp2-7-dev libgdk-pixbuf2.0-dev cmake checkinstall
sudo apt-get build-dep libpoppler-cpp-dev

cd ~/Downloads
wget https://poppler.freedesktop.org/poppler-0.73.0.tar.xz
tar -xf poppler-0.73.0.tar.xz
cd poppler-0.73.0

mkdir build
cd build
cmake ..
sudo checkinstall make install

Define the environment variable R_LD_LIBRARY_PATH to inform R about the Poppler libraries in /usr/local/lib:

echo "export R_LD_LIBRARY_PATH=\$R_LD_LIBRARY_PATH:/usr/local/lib" >> .bashrc

Compile the pdftools R-package inside R-shell:

install.packages("pdftools")

Test it from R-shell with any pdf-file

> pdftools::pdf_data(pdf="/usr/share/cups/data/default.pdf")
[1]]
[1] width  height x      y      space  text  
<0 rows> (or 0-length row.names)

I wanted to know:

  • would the answer also apply to Ubuntu 20.04 LTS? - I tried it, and it worked. However I realised later this is not be the best solution (see answers below).
  • would it also apply to any more recent version of poppler? - didn't try, as I didn't want to mess up my working setup with version 0.73.

Here is the output of dpkg -l | grep -i poppler after performing the above install (this is useful to determine how to uninstall, see below):

# dpkg -l | grep -i poppler
ii  build                                20200518-1                         amd64        poppler-0.73.0
ii  poppler-data                         0.4.9-2                            all          encoding data for the poppler PDF rendering library
#

Solution 1:

At first you need to remove self-compiled deb-package of Poppler named build:

sudo apt-get purge build

To install actual version of Poppler use package from repository:

sudo apt-get update
sudo apt-get install libpoppler-dev

And at next time - start from repository, build packages only if they are not available in the repositories. More detailed explanation is here.

Solution 2:

Use the following method to install Poppler in Ubuntu 20.04

Download Poppler

wget https://poppler.freedesktop.org/poppler-21.09.0.tar.xz
tar -xvf poppler-21.09.0.tar.xz

Install some dependencies(if missing)

sudo apt-get install libnss3 libnss3-dev
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev

Make install

cd poppler-21.09.0/
mkdir build
cd build/
cmake  -DCMAKE_BUILD_TYPE=Release   \
       -DCMAKE_INSTALL_PREFIX=/usr  \
       -DTESTDATADIR=$PWD/testfiles \
       -DENABLE_UNSTABLE_API_ABI_HEADERS=ON \
       ..
make 
sudo make install