PDFtk Server on OS X 10.11

MacosPdfHomebrewPdftkOsx Elcapitan

Macos Problem Overview


I've been using PDFTK Server on OSX pre 10.11 for over a year without any issues running commands on the command line.

After installing OSX 10.11 beta, I can no longer run any PDFTK Server commands on the command line. It does not throw any error, all the commands I try to execute just hang indefinitely.

I installed from a pkg I downloaded from the PDFTK Server website as always:

https://www.pdflabs.com/tools/pdftk-server/

I've also tried installing from source with Homebrew. The installation works, but I get the same results, the commands just hang in the terminal:

Homebrew tap

I've sent in the complaint to Apple via their Feedback Assistant application that gets installed when installing the beta two months ago without a response.

I've been told regarding the Apple Feedback Assistant:

> You likely won't ever receive a response. Apple only replies through > Feedback Assistant for major bugs of the operating system where they > need additional information. It is not a way to obtain support, even > less so for a third-party application.

I've also reached out to PDF Labs, the makers of the package, without response.

On MacPorts they're having an issue with the build on OS X 10.11, does this mean that there is a compatibility issue with PDFtk and 10.11 at the software level?

I've searched the web for a clue as to what might be causing the issue and how to fix it, but have found nothing tangible.

On OS X, I don't know how to go about figuring out if there is now a permission or path or even a Java issue after the upgrade.

Any help either trouble shooting the root cause or offering a fix is appreciated.


UPDATE 1:

I heard back from Sid Steward at PDF Labs:

> We have been wrestling with this almost as long as the beta has been > out. We are still working on it. There appears to be an > incompatibility with one of the (non-Apple) libraries that pdftk uses > and OS X 10.11. Presently I am installing yet another update to > Apple's developer tools with the hope that it will solve the problem. > I will update you with our progress.


UPDATE 2:

Sid Steward at PDF Labs again:

> It looks like there are two threads running under pdftk, and that they > are deadlocked. That means that each thread is waiting for the other > to finish. I'm not an expert here, but that's my impression. Here is a > screenshot from Mac's Activity Monitor to illustrate:

enter image description here

> The above snapshot is from trying to run the pdftk binary currently on > our site on OS X 10.11. The libgcj library noted above comes with > pdftk, where the others are OS X libraries. > > As I say, I just installed Xcode 7.0.1, which was released yesterday > on the App store. I will now attempt to use these tools to build > pdftk.


UPDATE 3:

MacPorts is working the build issue with PDFtk, this is an update on that thread (Note: this is unrelated to PDFtk Labs):

> This is due to the recompilation of libunwind in 10.11 using Apple > Clang 7 producing new valid optimizations (according to Apple) that > tickle an unknown bug in FSF boehm-gc.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66848

> Don't expect any fixes from Apple as they can't touch the GPLv3 code > to look at the FSF boehm-gc problem (unless they used the gcc43 > package which should still be GPLv2). That this issue is triggered by > the recompilation of libunwind is demonstrated by that fact that > substituting the libunwind.dylib from 10.10 eliminates both the > boehm-gc and gcj failures. > > Note that is was filed as radr://21372179, "the FSF boehm-gc library > built on 10.10 fails to pass its tests on 10.11" but closed as being > an FSF boehm-gc bug.


UPDATE 4:

MacPorts found a way to solve the build issue, this is an update on that thread

> The attached Portfile.diff (when used with the proposed gcc5 update on > #49227 which fixes gcj) solves the build issue with pdftk.


UPDATE 5:

Sid Steward at PDF Labs has a successful build, his feedback:

> A fix for MacPorts gcc5 allowed me to build a working pdftk that > merges PDFs on El Capitan. The fix was added to the ticket you had > posted to:

MacPorts

> I will proceed to fully test this pdftk before packing it up into an > installer. This process could take a couple days.


Macos Solutions


Solution 1 - Macos

Thank you for your patience. I have successfully tested this pdftk installer and binary on OS X 10.11, El Capitan:

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg

I will update our PDF Labs site soon to reflect this update.

If you already have pdftk installed from the old installer, this should install right on top of it without a problem -- it shouldn't be necessary to remove the old pdftk before installing this one.

Note that this installer/binary has not yet been tested on older versions of OS X.

Please let me know how this works for you.

I want to thank Aaron for opening this thread and for bringing helpful attention to the problem we were having with the build tools. I also want to thank the MacPorts team for their professional and timely work!

Solution 2 - Macos

Thanks to github.com/quantiverge, pdftk should be installable under brew. This one is tested in OSX Sierra.

Run the following in the terminal.

brew install https://raw.githubusercontent.com/turforlag/homebrew-cervezas/master/pdftk.rb

Updated with fixes from github.com/zph - thanks!

Solution 3 - Macos

###2020 Update

###WORKED: Please note that in order to install it on macOS High Sierra (10.13.5) or on Mac OS Catalina (10.15) (as mentioned by Ivan Kurmanov in the comments), I had to download the package from:

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg

Of course, it won't let you install normally as it's not downloaded from "App Store" so use following instructions:

  1. In the Finder, locate the app you want to open.

  2. Don’t use Launchpad to do this. Launchpad doesn’t allow you to access the shortcut menu.

  3. Control-click the app icon, then choose Open from the shortcut menu.

  4. Click Open.

  5. The app is saved as an exception to your security settings, and you can open it in the future by double-clicking it just as you can any registered app.

After that just go through the installation process, which is pretty much NEXT - NEXT and enjoy :)

###DID NOT WORK: The following brew command DID NOT work for me:

brew install https://raw.githubusercontent.com/turforlag/homebrew-cervezas/master/pdftk.rb

It gave following error:

> Failure while executing; /usr/bin/xar -xf > /xxxx/Library/Caches/Homebrew/downloads/\#\{url_sha256\}--\* exited > with 1.

Good luck!

Solution 4 - Macos

Pdftk is currently not working for me on OSX Sierra.

If you have docker installed on your system, you can use my lightweight docker image instead:

$ docker run -v $(pwd):/files alpine-pdftk --help

Even better, simply use the following script as a drop in replacement:

#!/usr/bin/env bash
docker run --rm -v $(pwd):/files jottr/alpine-pdftk "$@"

Now you can use pdftk as expected: ./pdftk --help

Solution 5 - Macos

work for me install the new one, https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg

remove the old pdftk version; search the pdftk from the finder, move to trash and also have pdftk_uninstall.sh done.

$ pdftk -version

pdftk 2.02 a Handy Tool for Manipulating PDF Documents Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com This is free software; see the source code for copying conditions. There is NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Solution 6 - Macos

@Learner I fixed the recipe here: https://github.com/zph/homebrew-cervezas/blob/master/pdftk.rb and submitted a PR to the repo you linked.

Until that's merged, you can install as:

brew install https://github.com/zph/homebrew-cervezas/blob/master/pdftk.rb

Or if using Homebrew Bundler, add to your Brewfile:

tap 'zph/homebrew-cervezas'
brew 'pdftk'

Solution 7 - Macos

Third Edit: The following are not fixes, but rather workarounds, (`cuz sometimes its not feasible to wait months for fixes to arrive).


Second Edit: Coherent PDF Command Line Tools (aka cpdf) is free for noncommercial use, and can be licensed for commercial use. It provides functionality comparable to pdtk and (on my MacBook Pro at least) seems to run OK under El Capitan.


Edit: This StackOverflow answer tells how to use ghostscript to concatenate files, thus providing (awkwardly) functionality similar to of "pdftk ... cat output out.pdf".


For some purposes, the package ghostscript---which ships with LaTeX distributions like texlive---offers similar (but less user-friendly) capability to pdftk.

E.g., to extract pages 6-7 from a multipage pdf document:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
  -dFirstPage=6 -dLastPage=7 \
  "-sOutputFile="${EXTRACTED_FILENAME_HERE}" \
  "${SOURCE_FILENAME_HERE}" ;

The above worked for me ... your mileage may vary!

Needless to say, restoring pdftk to full functionality under El Capitan would be much better ... pdftk really is a terrific utility.

Solution 8 - Macos

Workarounds: We raised this to Sid back in August and he still has not fixed it so I think its fair to say that its a good idea to look for alternatives. Because of this, we have taken the initiative to submit a few first tools that people can enjoy for free in the following repository:

https://github.com/flexpaper/OSX-PDF-Toolkit

It contains easy to use scripts for CAT and BURST. We intend to add more tools going forward. Feel free to contribute

These new tools are using the native OSX libraries and no third party dependencies are needed whatsoever. Yay!

Edit: added info about this being a workaround

Solution 9 - Macos

You can get to a running PDFTK Server under El Capitan if you use the manual of patching ports together with the four patches provided in Macports tickets #48528 and #49227.

The compilation of patched GCC5 took a long time on my machine. Also, it seems to be a good idea to name the local ports identically to the original ones (i.e. gcc5 and pdftk), otherwise you have to adjust the Portfiles.

It is also possible to bundle the resulting pdftk binary together with its dynamic libraries using install_name_tool on the binary and the dynamic libraries. I succeeded to run pdftk this way on two other machines.

Solution 10 - Macos

Updated status as of 2018-05-09:

  1. It's not on brew standard sources
  2. https://github.com/spl/homebrew-pdftk is unmaintained / deprecated
  3. It is at https://www.pdflabs.com/tools/pdftk-server/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAaronView Question on Stackoverflow
Solution 1 - MacosSid StewardView Answer on Stackoverflow
Solution 2 - MacosobhView Answer on Stackoverflow
Solution 3 - MacosAbhay MauryaView Answer on Stackoverflow
Solution 4 - MacosjottrView Answer on Stackoverflow
Solution 5 - MacostralalaView Answer on Stackoverflow
Solution 6 - MacosZPHView Answer on Stackoverflow
Solution 7 - MacosJohn SidlesView Answer on Stackoverflow
Solution 8 - MacosFlowPaper TeamView Answer on Stackoverflow
Solution 9 - MacosFrank P.View Answer on Stackoverflow
Solution 10 - MacosSaiView Answer on Stackoverflow