Skip to content

Instantly share code, notes, and snippets.

@jvenator
Last active February 19, 2025 19:15
Show Gist options
  • Save jvenator/9672772a631c117da151 to your computer and use it in GitHub Desktop.
Save jvenator/9672772a631c117da151 to your computer and use it in GitHub Desktop.
PDFtk Server Install Workaround for Mac OS X

Installing PDFtk Server edittion on your Mac

This workaround install is necessary because PDFtk was pulled from homebrew-cask due to issues with it aggressively overwriting file permissions that could impact other installed libraries. See this homebrew-cask issue.
The following steps worked on Mac OS X 10.10.1 with a standard brew installation for the PDFtk Mac OS X server libary version 2.02.
All Terminal commands separated by a full line space. Some commands wrap into multiple lines.

Download and extract the Mac OS X server install pacakge

curl -o ~/Downloads/pdftk_download.pkg https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.6-setup.pkg
pkgutil --expand ~/Downloads/pdftk_download.pkg ~/Downloads/pdftk_package

Now create directories for where it would go with a proper brew install.

*NOTE: I had no prior install of PDFtk via brew-cask when doing this. Not sure how having multiple versions installed might affect brew link and these instructions.

cd ~ && mkdir /usr/local/Cellar/pdftk /usr/local/Cellar/pdftk/2.02 /usr/local/Cellar/pdftk/2.02/bin /usr/local/Cellar/pdftk/2.02/lib /usr/local/Cellar/pdftk/2.02/share /usr/local/Cellar/pdftk/2.02/share/man /usr/local/Cellar/pdftk/2.02/share/man/man1

Here are the individual directories being created above (assume being in cd ~ directory).

mkdir /usr/local/Cellar/pdftk

mkdir /usr/local/Cellar/pdftk/2.02

mkdir /usr/local/Cellar/pdftk/2.02/bin

mkdir /usr/local/Cellar/pdftk/2.02/lib

mkdir /usr/local/Cellar/pdftk/2.02/share

mkdir /usr/local/Cellar/pdftk/2.02/share/man

mkdir /usr/local/Cellar/pdftk/2.02/share/man/man1

Give the Payload file the proper gzip file extension and unzip it

mv ~/Downloads/pdftk_package/pdftk.pkg/Payload ~/Downloads/pdftk_package/pdftk.pkg/payload.gz
gunzip ~/Downloads/pdftk_package/pdftk.pkg/payload.gz

Use cpio to unarchive the resulting file

cd ~/Downloads/pdftk_package/pdftk.pkg/ && cpio -iv < ~/Downloads/pdftk_package/pdftk.pkg/payload && cd ~

Move the relevant extracted files to their appropriate locations within the Cellar/pdftk directory

cd ~ && mv Downloads/pdftk_package/pdftk.pkg/bin/pdftk /usr/local/Cellar/pdftk/2.02/bin/pdftk && mv Downloads/pdftk_package/pdftk.pkg/lib/* /usr/local/Cellar/pdftk/2.02/lib/ && mv Downloads/pdftk_package/pdftk.pkg/man/pdftk.1 /usr/local/Cellar/pdftk/2.02/share/man/man1/pdftk.1

Or the individual file moves (assume being in cd ~ directory)

mv Downloads/pdftk_package/pdftk.pkg/bin/pdftk /usr/local/Cellar/pdftk/2.02/bin/pdftk
mv Downloads/pdftk_package/pdftk.pkg/lib/* /usr/local/Cellar/pdftk/2.02/lib/
mv Downloads/pdftk_package/pdftk.pkg/man/pdftk.1 /usr/local/Cellar/pdftk/2.02/share/man/man1/pdftk.1

Create the appropriate symlinks through brew

brew doctor

and most likely then

brew link pdftk

@PeterNSteinmetz
Copy link

Also worked for me on Apple M2 Max, Sonoma 14.6.1.

@elly-belfort
Copy link

I had to edit to account for the fact that my Homebrew Cellar directory was under /opt/homebrew/, not /usr/local/:
mkdir /opt/homebrew/Cellar/pdftk
/opt/homebrew/Cellar/pdftk/2.02
/opt/homebrew/Cellar/pdftk/2.02/bin
/opt/homebrew/Cellar/pdftk/2.02/lib
/opt/homebrew/Cellar/pdftk/2.02/share
/opt/homebrew/Cellar/pdftk/2.02/share/man
/opt/homebrew/Cellar/pdftk/2.02/share/man/man1

mv ~/Downloads/pdftk_package/pdftk.pkg/Payload ~/Downloads/pdftk_package/pdftk.pkg/payload.gz

gunzip ~/Downloads/pdftk_package/pdftk.pkg/payload.gz

cd ~/Downloads/pdftk_package/pdftk.pkg/

cpio -iv < ~/Downloads/pdftk_package/pdftk.pkg/payload

cd ~

mv Downloads/pdftk_package/pdftk.pkg/bin/pdftk /opt/homebrew/Cellar/pdftk/2.02/bin/pdftk
mv Downloads/pdftk_package/pdftk.pkg/lib/* /opt/homebrew/Cellar/pdftk/2.02/lib/
mv Downloads/pdftk_package/pdftk.pkg/man/pdftk.1 /opt/homebrew/Cellar/pdftk/2.02/share/man/man1/pdftk.1

brew doctor

brew link pdftk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment