How to install pdftk on Mac OS X [closed]
Asked Answered
F

3

85

I want to install pdftk with MacPorts, but this command does not work:

 sudo apt-get install pdftk

Is it possible to install it on a Mac?

My system specifications are:

Processor: 2.5 GHz Intel Core i5
Memory:    8 GB 1600 MHz DDR3
Graphics:  Intel HD Graphics 4000 768 MB
Feder answered 27/12, 2013 at 16:48 Comment(8)
apt-get is for linux, have you tried sudo port install pdftk?Michelinamicheline
yes, you are right. i made mistake.Great!Feder
PyPDF2 provides an alternative script pdfcat pythonhosted.org/PyPDF2/Easy%20Concatenation%20Script.html just in case people still get attracted here from google search result.Ziska
You can install it from the official site pdflabs.com/tools/pdftk-serverAssume
2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: https://mcmap.net/q/246368/-how-to-solve-quot-pdftk-bad-cpu-type-in-executable-quot-on-mac. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.Cabriolet
2022 Update: This worked for me: pdflabs.com/tools/pdftk-the-pdf-toolkit/…Dildo
2022 Sept 13 : original author of pdftk posted this PKG here : https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11 , and this worked on macOS Monterey (12.5.1).Kannry
To install it using homebrew (as of october 2022), see this answer: https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11Sparry
L
67

You can use the official installer from PDF Labs.

Edit: It’s now available through homebrew-cask too. If you have that installed, you can just run

brew cask install pdftk

to install pdftk.

There is no longer a Cask package available, so you will have to defer to the original solution or follow this workaround

Landin answered 27/12, 2013 at 16:57 Comment(14)
just adding something that came up to me - I needed run brew update && brew upgrade brew-caskNanice
@JonatasCD Thanks for the command. It worked after I updated and upgraded.Fifth
An anonymous user points out that pdftk has temporarily been removed from homebrew-cask due to this issue. Follow that link for more information.Landin
It is not working anymore.Parttime
@Parttime I get an error trying to install also. What is the best way to install it?Infrangible
@Infrangible In our project decided to use a pure Ubuntu VM through Vagrant as pdftk and other plugins have issues in Mac.Parttime
@Infrangible Have you tried the PDF Labs installer I mentioned at the beginning of the answer?Landin
Here's a step-by-step copy-paste brew cask install pdftk workaround -- worked perfectly for me.Babb
@JoelPurra I forked the gist and added all the commands to a script. That can be run instead of doing 15 copy-pastes.Macassar
@scottgwald: didn't have the time when I found the gist, so happy that you did it. Great, thanks!Babb
@JoelPurra sure thing! time will tell how brittle all of those paths are, hahaMacassar
The official install does NOT work on 10.11 beta and any and all brew installs/work arounds that I've found do NOT work either. I've had pdftk working on 10.9 and 10.10 without issues.Driven
In case anyone is still looking, this is the download link that works on El Capitan. https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkgSuperaltar
2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: https://mcmap.net/q/246368/-how-to-solve-quot-pdftk-bad-cpu-type-in-executable-quot-on-mac. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.Cabriolet
C
80

From quantiverge PR on brew:

brew install https://raw.github.com/quantiverge/homebrew-binary/pdftk/pdftk.rb
Codd answered 26/2, 2014 at 21:45 Comment(17)
Worked for me on Mavericks. Sadly compiling from source has so many dependencies that it takes forever, so this is a nice shortcut for the meantime.Platinum
Still working on 10.9.5Lagas
Works on Yosemite (OS X 10.10) as well.. :)Dejecta
We used the answer provided by Sean Leather, sorry couldn't find his @username it is the bottom answer on this post (as of this comment)Infrangible
works on Yosemite 10.10.4 (y)Placement
The official install does NOT work on 10.11 beta and any and all brew installs/work arounds that I've found do NOT work either. I've had pdftk working on 10.9 and 10.10 without issues.Driven
Works on El Capitan 10.11 just fine!Exultation
@Exultation I unfortunately had the same experience myself. Seems like it works and then just hangs.Superaltar
Works on Sierra 10.12Chophouse
The formula doesn't work with current brew, use brew install https://raw.githubusercontent.com/youtux/homebrew-binary/pdftk/pdftk.rb from youtux's PR instead.Organize
That just installs pdftk using the official pkg installer.Vibraphone
Up-to-date version of this solution here: https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11 Command is: brew install https://raw.githubusercontent.com/turforlag/homebrew-cervezas/master/pdftk.rbGinkgo
Please note as of Aug 2017, none of the above works. The link posted by @JoshBuchea is the only thing that works.Sweetsop
2018-06-12: @JoshBuchea's link worked for me: brew install raw.githubusercontent.com/turforlag/homebrew-cervezas/master/…Flogging
Error: pdftk: undefined method `sha1' for #<Class:0x0000000101c9d270>Ivonneivor
2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: https://mcmap.net/q/246368/-how-to-solve-quot-pdftk-bad-cpu-type-in-executable-quot-on-mac. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.Cabriolet
Error: Non-checksummed download of pdftk formula file from an arbitrary URL is unsupported! `brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.Centrist
L
67

You can use the official installer from PDF Labs.

Edit: It’s now available through homebrew-cask too. If you have that installed, you can just run

brew cask install pdftk

to install pdftk.

There is no longer a Cask package available, so you will have to defer to the original solution or follow this workaround

Landin answered 27/12, 2013 at 16:57 Comment(14)
just adding something that came up to me - I needed run brew update && brew upgrade brew-caskNanice
@JonatasCD Thanks for the command. It worked after I updated and upgraded.Fifth
An anonymous user points out that pdftk has temporarily been removed from homebrew-cask due to this issue. Follow that link for more information.Landin
It is not working anymore.Parttime
@Parttime I get an error trying to install also. What is the best way to install it?Infrangible
@Infrangible In our project decided to use a pure Ubuntu VM through Vagrant as pdftk and other plugins have issues in Mac.Parttime
@Infrangible Have you tried the PDF Labs installer I mentioned at the beginning of the answer?Landin
Here's a step-by-step copy-paste brew cask install pdftk workaround -- worked perfectly for me.Babb
@JoelPurra I forked the gist and added all the commands to a script. That can be run instead of doing 15 copy-pastes.Macassar
@scottgwald: didn't have the time when I found the gist, so happy that you did it. Great, thanks!Babb
@JoelPurra sure thing! time will tell how brittle all of those paths are, hahaMacassar
The official install does NOT work on 10.11 beta and any and all brew installs/work arounds that I've found do NOT work either. I've had pdftk working on 10.9 and 10.10 without issues.Driven
In case anyone is still looking, this is the download link that works on El Capitan. https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkgSuperaltar
2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: https://mcmap.net/q/246368/-how-to-solve-quot-pdftk-bad-cpu-type-in-executable-quot-on-mac. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.Cabriolet
C
42

I created a pdftk homebrew tap:

brew tap spl/pdftk
brew install pdftk

The current formula depends on a specific compiler (gcc48) with a specific build flag (enable-all-languages). This is only be a problem if you happen to already have gcc48 without the flag or if you have a different version of gcc. You can, of course, clone the formula and change it for your situation. But, unfortunately, nobody has answered my question about alternative dependencies, so I don't know how to resolve this.

Update 1 (2015-03-19): As of this change (described in my solution to alternative dependencies), the formula now supports multiple versions of gcc and different flags.

Update 2 (2016-01-12): For OS X 10.11 El Capitan users, the source build of pdftk does not seem to work. There is a .pkg available at https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11 . As of this date, PDF Labs has not yet released a source update that fixes the build.

Curium answered 12/2, 2014 at 6:53 Comment(12)
it takes forever on my pro late 2011 to install gcc, not my wayTaneka
I have found the same as @gaussblurinc. Mid 2011 iMac - taking an age to install the gcc dependency. Far more tempted to ditch pdftk and find a lighter alternative.Layby
This took forever for me too. I used the answer below (install from raw.github.com and it's working fine)Spradling
@Aaron, Does my Homebrew tap also not work? It installs from source and not from the .pkg.Curium
I tried to install from Homebrew and the install worked on 10.11, yes -- but the actual executable just hangs anytime you try to run commands. Warning: I've been using pdftk for over a year and installed from Homebrew and from www.pdflabs.com at times, and things worked fine. After 10.11 nothing works no matter how you install it. So pdftk is broke on 10.11. Here's my SO question on the topic: https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11Driven
@Driven I've had the same broken experience myself so far.Superaltar
@Coenosarc see: https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11Driven
@Driven Thanks! Yes, this worked for me: https://mcmap.net/q/47308/-pdftk-server-on-os-x-10-11Coenosarc
Thanks for the comments, folks. I've updated my answer to point to the other answer. If you discover a way to build a working (possibly patched) pdftk from source on El Capitan, please let me know (either here or on GitHub).Curium
Thanks for the second update... the docmunch cask tap seems to be hanging on an OSX patch. But the link to the .pkg helped me get it installed.Foresight
@SeanLeather the installation does not work anymore. It gets stuck at installing gcc 6.3.0Latoyialatreece
2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: https://mcmap.net/q/246368/-how-to-solve-quot-pdftk-bad-cpu-type-in-executable-quot-on-mac. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.Cabriolet

© 2022 - 2024 — McMap. All rights reserved.