4

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
#
jimbod119
  • 143
  • 1
  • 1
  • 6

2 Answers2

13

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
  • 1
    I also needed to do sudo apt install libopenjp2-7-dev -y (poppler-22.04.0) – Ido Apr 16 '22 at 18:44
  • 1
    @CodeProcessor Thank you for saving me a lot of headache figuring out the dependencies. – Dhawan Gayash Jul 23 '23 at 03:43
  • 1
    Thank you! Installing libpoppler-dev and poppler-utils did not resolve the issue for me - only building from source as you've describe here, worked. (Ubuntu 18.04, Python 3.8, using with pdf2image which is what was complaining that it couldn't find poppler) – James_SO Aug 08 '23 at 17:48
10

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.

N0rbert
  • 99,918
  • Thanks a lot Norbert, that answers how to install it. I suppose I would have first to undo the installation of Poppler 0.73? (how?) And more fundamentally, if I may ask, how could I have checked and found out by myself that the package existed with that name in a repository (I'm not even sure which repository, nor whether it has to be added to my /etc/apt/sources.list file) and for that version of Ubuntu? (other than asking on Ask Ubuntu)? – jimbod119 May 18 '20 at 19:04
  • See updated answer above. About packages the APT command-line utils and http://packages.ubuntu.com site provide information about the official repositories. More info: https://help.ubuntu.com/lts/ubuntu-help/addremove.html.en for desktop and https://ubuntu.com/server/docs/package-management for server. – N0rbert May 18 '20 at 19:59
  • many thanks for the additional links, much appreciated! – jimbod119 May 18 '20 at 20:19
  • 1
    In my case I needed pdfinfo which I had to install using apt install poppler-utils. – nikhilweee Apr 04 '23 at 20:17