I want to use pdftk but I always get this error zsh: bad CPU type in executable: pdftk
I reinstalled pdftk and I changed the terminal from bsh to zsh as I found in my search for how to solve this error but without any success. I'm using the latest MacOS version "Catalina v10.15.4"

- 1,057
- 1
- 12
- 24
5 Answers
This version of pdftk works on macOS Catalina (10.15).
https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg
The link on the website is not up to date. That means by clicking the download button on the website you get an old version.

- 1,865
- 1
- 9
- 10
-
12Works on Big Sur (OSX 11) on M1 as well! – Individual11 Dec 20 '20 at 13:31
-
5This "WHY" moment brought to you by the internet – rosstex Feb 26 '21 at 09:09
-
2This works (Big Sur on Intel). Sent email to author, asking him to fix link. – Tom Hundt Apr 08 '21 at 20:42
-
6Works on Monterey on M1 too – goodniceweb Dec 24 '21 at 20:28
-
5Confirm, works on M1 without any extra effort, just run the "pdftk" command as usual. – jholster Jan 28 '22 at 08:22
-
Work Perfectly on macOs Big Sur Version 11.6 by just installing the Packeg. Thanks Men. – Hafiz Abdul Rehman May 06 '22 at 09:48
-
Just to note now, this version is pretty out of date, and was throwing exception when trying to fill data into a PDF of mine. The version installed from homebrew as per gatorback's answer is 3.3.3 (and fixes the exceptions I was receiving) – Luke Jan 18 '23 at 08:01
Homebrew:
brew install pdftk-java
https://formulae.brew.sh/formula/pdftk-java
Compatible with Catalina, Big Sur

- 1,351
- 4
- 19
- 44
-
-
1
-
Note this is a Java *port* and is not the original pdftk. As such there may be bugs, known differences, and be feature incomplete or have additional features. – Dennis Aug 04 '23 at 10:44
Following Ben's answer, here is a bash script that search for the latest available PDFTK version from their website:
#!/bin/bash
PDFTK_VERSION="2.02"
MACOS_VERSION_MAJOR_START="10"
MACOS_VERSION_MAJOR_END="12"
MACOS_VERSION_MINOR_START="0"
MACOS_VERSION_MINOR_END="20"
DOWNLOAD_URL="https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-PDFTK_VERSION-mac_osx-MACOS_VERSION_MAJOR.MACOS_VERSION_MINOR-setup.pkg"
# Check if we want debug mode or not
if [[ "$1" == "debug" ]]; then
DEBUG="YES"
fi
# Function that check if a file exist with curl
check_url_exist() {
http_code=$( curl --output /dev/null --silent --head --fail -w '%{http_code}' "$1" 2>/dev/null )
if [[ "$http_code" == "200" ]]; then
echo "YES"
else
echo "NO"
fi
}
echo "INFO - Searching for PDFTK version $PDFTK_VERSION, from MacOS version $MACOS_VERSION_MAJOR_START.$MACOS_VERSION_MINOR_START to $MACOS_VERSION_MAJOR_END.$MACOS_VERSION_MINOR_END."
# Search for available versions
MAJOR="$MACOS_VERSION_MAJOR_START"
while [ $MAJOR -le $MACOS_VERSION_MAJOR_END ]; do
MINOR="$MACOS_VERSION_MINOR_START"
while [ $MINOR -le $MACOS_VERSION_MINOR_END ]; do
THIS_DOWNLOAD_URL=$( echo "$DOWNLOAD_URL" | sed -e "s|PDFTK_VERSION|$PDFTK_VERSION|g" | sed -e "s|MACOS_VERSION_MAJOR|$MAJOR|g" | sed -e "s|MACOS_VERSION_MINOR|$MINOR|g" )
if [[ $( check_url_exist "$THIS_DOWNLOAD_URL" ) == "YES" ]]; then
echo "FOUND - Found version ! PDFTK:$PDFTK_VERSION, MacOS:$MAJOR.$MINOR. URL: $THIS_DOWNLOAD_URL"
elif [[ "$DEBUG" == "YES" ]]; then
echo "NOT FOUND - PDFTK:$PDFTK_VERSION, MacOS:$MAJOR.$MINOR. URL: $THIS_DOWNLOAD_URL"
fi
MINOR=$(( MINOR + 1))
sleep 0.2
done
MAJOR=$(( MAJOR + 1))
done
And the result, at the date of 2022-10-15, is :
$ bash ./download_pdftk_mac.sh
INFO - Searching for PDFTK version 2.02, from MacOS version 10.0 to 12.20.
FOUND - Found version ! PDFTK:2.02, MacOS:10.6. URL: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.6-setup.pkg
FOUND - Found version ! PDFTK:2.02, MacOS:10.11. URL: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg

- 35
- 3
As a preliminary solution, I was successful in installing the Intel version of homebrew in /usr/local (in parallel to the M1 version in /opt/homebrew) using Apple's Rosetta 2 layer. The Intel packages (homebrew formulae) seem to work without any problem on the Apple M1 architecture. Both pdftk and pandoc work even without prefixing 'arch -x86_64' (e.g., the command 'pandoc sample.md -o sample.html' as in the example linked below).
Commands:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
alias ibrew='arch -x86_64 /usr/local/bin/brew'
ibrew analytics off
ibrew install pdftk-java
ibrew install pandoc
Further information:

- 11
- 1
-
1You can just install the package mentioned in Ben's answer, no extra hacks needed on M1. – jholster Jan 28 '22 at 08:23
-
Yes, as a workaround I had also mentioned it [here](https://github.com/Homebrew/formulae.brew.sh/issues/467#issuecomment-841846989). But it seems to be an old version (2.02). Now homebrew directly supports the M1 chip ("Apple Silicon"), with pdftk-java version 3.3.2, which I consider the better solution: https://formulae.brew.sh/formula/pdftk-java#default – kkbt Jan 29 '22 at 13:17
-
I still get the error pdftk ✔ took 8s at 08:05:51 PM zsh: bad CPU type in executable: pdftk – Mona Jalal Oct 01 '22 at 00:06
-
If the Apple Silicon variant supported by [https://formulae.brew.sh/formula/pdftk-java](https://formulae.brew.sh/formula/pdftk-java) doesn't work, the forum at [https://gitlab.com/pdftk-java/pdftk/-/issues](https://gitlab.com/pdftk-java/pdftk/-/issues) might be the right place to ask for support. In my case it's working fine: pdftk-java: stable 3.3.2 (bottled). – kkbt Oct 02 '22 at 04:35