Skip to content

Instantly share code, notes, and snippets.

@sheershoff
Last active December 12, 2022 13:59
Show Gist options
  • Save sheershoff/a1e068b3f6ed60ed87f56a9e5dce312b to your computer and use it in GitHub Desktop.
Save sheershoff/a1e068b3f6ed60ed87f56a9e5dce312b to your computer and use it in GitHub Desktop.
pdftk CLI for ubuntu 18.04 or later in docker replacement
#!/bin/bash
# Build or use cached image and tag with "local/local/ubuntu_pdftk", suppress output
# to maintain compatibility in case you are parsing the pdftk output.
# It will build the image if it's absent or use the cached one.
echo "FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y pdftk && \
rm -rf /var/lib/apt/lists/*" | docker build -t local/local/ubuntu_pdftk - 2>&1 > /dev/null
# Run the pdftk
set -eu
docker run --name pdftk -it --rm --user $(id -u):$(id -g) -v "$PWD:/workdir$PWD" -w "/workdir$PWD" local/local/ubuntu_pdftk pdftk "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment