添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers . If you believe the question would be on-topic on another Stack Exchange site , you can leave a comment to explain where the question may be able to be answered.

Closed 9 years ago .

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
                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.
– Dyno Fu
                Mar 17, 2015 at 22:39
                2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: stackoverflow.com/a/60889993/293280. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error.
– Joshua Pinter
                Jan 12, 2021 at 15:58
                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.
– tan9
                Dec 17, 2016 at 14:16
                Up-to-date version of this solution here: stackoverflow.com/a/41243285/1492782 Command is: brew install https://raw.githubusercontent.com/turforlag/homebrew-cervezas/master/pdftk.rb
– Josh Buchea
                Jun 27, 2017 at 21:03
                Please note as of Aug 2017, none of the above works. The link posted by @JoshBuchea is the only thing that works.
– SmallChess
                Aug 9, 2017 at 1:49

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

just adding something that came up to me - I needed run brew update && brew upgrade brew-cask – Jonatas CD May 20, 2014 at 17:23 An anonymous user points out that pdftk has temporarily been removed from homebrew-cask due to this issue. Follow that link for more information. – bdesham Dec 4, 2014 at 18:18 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.pkg – james-see Nov 25, 2015 at 13:53 2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: stackoverflow.com/a/60889993/293280. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error. – Joshua Pinter Jan 12, 2021 at 15:58

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://stackoverflow.com/a/33248310/545794 . As of this date, PDF Labs has not yet released a source update that fixes the build.

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. – freethebees Jun 2, 2015 at 14:39 This took forever for me too. I used the answer below (install from raw.github.com and it's working fine) – jraede Jul 10, 2015 at 2:31 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: stackoverflow.com/questions/32505951/pdftk-server-on-os-x-10-11 – Aaron Sep 11, 2015 at 20:50 2021 Jan 12: Only thing that worked on macOS Big Sur was the link from this answer: stackoverflow.com/a/60889993/293280. Using the download link from the official website downloads an old installer and you get a zsh: bad CPU type in executable: pdftk error. – Joshua Pinter Jan 12, 2021 at 15:58