1

Below is the dockerfile that I am using

FROM python:3.6-slim
RUN apt update
RUN apt install poppler-utils -y
RUN apt install git -y
WORKDIR /src/
ADD . /src
CMD tail -f /dev/null

when I check the version of poppler using pdftocairo -v , I get 0.71 as the poppler version. I need to install specific version(0.82) of poppler with a python baseimage

neeraj mdas
  • 163
  • 3
  • 15

2 Answers2

4

At the time of writing this answer, the latest version of the Poppler is 20.08.0. If you want to use this version in your Docker image, you can do it as follows:

  1. Create a Dockerfile with the following content

    FROM python:3.8-slim-buster
    RUN apt-get update && apt-get install wget build-essential cmake libfreetype6-dev pkg-config libfontconfig-dev libjpeg-dev libopenjp2-7-dev -y
    RUN wget https://poppler.freedesktop.org/poppler-data-0.4.9.tar.gz \
        && tar -xf poppler-data-0.4.9.tar.gz \
        && cd poppler-data-0.4.9 \
        && make install \
        && cd .. \
        && wget https://poppler.freedesktop.org/poppler-20.08.0.tar.xz \
        && tar -xf poppler-20.08.0.tar.xz \
        && cd poppler-20.08.0 \
        && mkdir build \
        && cd build \
        && cmake .. \
        && make \
        && make install \
        && ldconfig
    CMD tail -f /dev/null
    
  2. Build and run your image

    docker build -t milanhlinak/poppler .
    docker run --name poppler milanhlinak/poppler
    
  3. Verify that Poppler was installed

    PS C:\Users\Milan\poppler-docker> docker exec -it poppler pdftotext -v
    pdftotext version 20.08.0
    Copyright 2005-2020 The Poppler Developers - http://poppler.freedesktop.org
    Copyright 1996-2011 Glyph & Cog, LLC
    

You can also check https://hub.docker.com/r/milanhlinak/poppler/

Milan Hlinák
  • 4,260
  • 1
  • 30
  • 41
  • 1
    How would I make it a static build binary? I just need pdfinfo to run in AWS labmda. – Teebu Dec 14 '20 at 23:10
  • Many thanks. This worked great trying to run the latest version of poppler on Amazon Linux. – zethw Mar 23 '21 at 01:24
0

Adding to Milan's response and updating it with the latest versions of poppler. Also adding support for pdftocairo and ability to output as tiff.

FROM python:3.8-slim-buster
RUN apt-get update && apt-get install apt-utils wget build-essential cmake libfreetype6-dev pkg-config libfontconfig-dev libjpeg-dev libopenjp2-7-dev libcairo2-dev libtiff5-dev -y
RUN wget https://poppler.freedesktop.org/poppler-data-0.4.10.tar.gz \
    && tar -xf poppler-data-0.4.10.tar.gz \
    && cd poppler-data-0.4.10 \
    && make install \
    && cd .. \
    && wget https://poppler.freedesktop.org/poppler-21.03.0.tar.xz \
    && tar -xf poppler-21.03.0.tar.xz \
    && cd poppler-21.03.0 \
    && mkdir build \
    && cd build \
    && cmake .. \
    && make \
    && make install \
    && cd ../.. \
    && ldconfig \
    && rm poppler-data-0.4.10.tar.gz \
    && rm -rf poppler-data-0.4.10 \
    && rm poppler-21.03.0.tar.xz \
    && rm -rf poppler-21.03.0
CMD tail -f /dev/null
zethw
  • 323
  • 1
  • 12