OS X 10.11 上的 PDFtk 服务器

PDFtk Server on OS X 10.11

我已经在 OSX pre 10.11 上使用 PDFTK 服务器一年多了,在命令行上没有任何问题 运行ning 命令。

安装 OSX 10.11 beta 后,我无法再在命令行上 运行 任何 PDFTK 服务器命令。它不会抛出任何错误,我尝试执行的所有命令都会无限期地挂起。

我一如既往地从 PDFTK 服务器网站下载的 pkg 安装:

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

我也尝试过使用 Homebrew 从源代码安装。安装有效,但我得到相同的结果,命令只是挂在终端中:

Homebrew tap

我已经通过他们的反馈助手应用程序向 Apple 投诉,该应用程序是在两个月前安装测试版时安装的,但没有得到回应。

有人告诉我有关 Apple 反馈助手的信息:

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.

我也联系了包的制造商 PDF Labs,但没有得到回应。

MacPorts 他们在 OS X 10.11 上构建时遇到问题,这是否意味着软件中的 PDFtk 和 10.11 存在兼容性问题等级?

我在网上搜索了有关可能导致问题的原因以及解决方法的线索,但没有找到任何有形的东西。

在 OS X 上,我不知道如何确定升级后是否存在权限或路径甚至 Java 问题。

任何帮助解决根本原因或提供修复的帮助都将不胜感激。


更新 1:

我收到了 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.


更新 2:

Sid Steward at PDF Labs 再一次:

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:

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.


更新 3:

MacPorts 正在解决 PDFtk 的构建问题,这是该线程的 更新 (注意:这与 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.


更新 4:

MacPorts 找到了解决构建问题的方法,这是该线程上的 更新

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


更新 5:

Sid Steward at PDF Labs构建成功,他的反馈:

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.


第三次编辑:以下不是修复,而是解决方法,(`因为有时等待数月才能到达修复是不可行的)。


第二次编辑: Coherent PDF Command Line Tools(又名cpdf)对于非商业用途是免费的,并且可以被许可用于商业用途。它提供的功能可与 pdtk 媲美,并且(至少在我的 MacBook Pro 上)在 El Capitan 下似乎 运行 OK。


编辑: 这个 Whosebug answer 告诉我们如何使用 ghostscript 连接文件,从而提供类似于 "pdftk ... cat output out.pdf" 的(笨拙的)功能.


出于某些目的,包 ghostscript--- 与 texlive 等 LaTeX 发行版一起提供---提供与 pdftk 类似(但用户友好性较低)的功能。

例如,从多页 pdf 文档中提取第 6-7 页:

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

以上对我有用......你的里程可能会有所不同!

不用说,将 pdftk 恢复到 El Capitan 下的完整功能会好得多...... pdftk 确实是一个了不起的实用程序。

解决方法: 我们在 8 月份向 Sid 提出了这个问题,但他仍然没有修复它,所以我认为可以公平地说,寻找替代方案是个好主意。因此,我们主动在以下存储库中提交了一些人们可以免费使用的第一批工具:

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

它包含易于使用的 CAT 和 BURST 脚本。我们打算在未来添加更多工具。欢迎贡献

这些新工具使用原生 OSX 库,不需要任何第三方依赖项。耶!

编辑:添加了有关此作为解决方法的信息

如果您使用 manual of patching ports together with the four patches provided in Macports tickets #48528 和 #49227,您可以在 El Capitan 下访问 运行ning PDFTK 服务器。

在我的机器上编译打过补丁的 GCC5 花了很长时间。此外,将本地端口命名为与原始端口相同的名称(即 gcc5 和 pdftk)似乎是个好主意,否则您必须调整端口文件。

也可以使用 install_name_tool 将生成的 pdftk 二进制文件与其动态库捆绑在一起 在二进制和动态库上。我在另外两台机器上以这种方式成功 运行 pdftk。

感谢您的耐心等待。我已经在 OS X 10.11, El Capitan:

上成功测试了这个 pdftk 安装程序和二进制文件

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

我会尽快更新我们的 PDF Labs 网站以反映这一更新。

如果您已经从旧的安装程序中安装了 pdftk,那么应该可以毫无问题地直接安装在它上面——在安装这个之前不需要删除旧的 pdftk。

请注意,此 installer/binary 尚未在旧版本的 OS X 上进行测试。

请告诉我这对你有何作用。

我要感谢 Aaron 打开此线程并帮助关注我们在构建工具方面遇到的问题。我还要感谢 MacPorts 团队的专业和及时的工作!

帮我安装新的,https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg

删除旧的pdftk版本; 从查找器中搜索 pdftk,移至回收站并完成 pdftk_uninstall.sh。

$ pdftk -version

pdftk 2.02 操作 PDF 文档的便捷工具 版权所有 (c) 2003-13 Steward and Lee, LLC - 请访问:www.pdftk.com 这是免费软件;查看复制条件的源代码。有 不提供任何保证,甚至不提供针对特定用途的适销性或适用性。

Pdftk 目前无法在 OSX Sierra 上为我工作。

如果您有 docker installed on your system, you can use my lightweight docker image

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

更好的是,只需使用以下脚本作为替代:

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

现在您可以按预期使用 pdftk 了:./pdftk --help

感谢 github.com/quantiverge,pdftk 应该可以在 brew 下安装。这个在 OSX Sierra 中测试过。

运行 终端中的以下内容。

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

更新了来自 github 的修正。com/zph - 谢谢!

截至 2018 年 5 月 9 日的更新状态:

  1. 它不在 brew 标准源上
  2. https://github.com/spl/homebrew-pdftk 未维护/已弃用
  3. https://www.pdflabs.com/tools/pdftk-server/

2020 更新

工作:

请注意,为了在 macOS High Sierra (10.13.5)Mac OS Catalina (10.15)(正如 Ivan Kurmanov 在评论中提到的),我不得不从以下位置下载软件包:

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

当然,它不会让你正常安装,因为它不是从 "App Store" 下载的,所以请使用以下说明:

  1. 在 Finder 中,找到您要打开的应用程序。

  2. 请勿使用 Launchpad 执行此操作。 Launchpad 不允许您访问快捷菜单。

  3. 按住 Control 键并单击应用程序图标,然后从快捷菜单中选择“打开”。

  4. 单击“打开”。

  5. 该应用程序已保存为您的安全设置的例外,您以后可以像打开任何已注册的应用程序一样通过双击打开它。

之后只需完成安装过程,这几乎就是 NEXT - NEXT 并享受 :)

没有成功:

以下 brew 命令对我有用:

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

它给出了以下错误:

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

祝你好运!

@Learner 我在此处修改了食谱:https://github.com/zph/homebrew-cervezas/blob/master/pdftk.rb 并向您链接的回购提交了 PR。

在合并之前,您可以安装为:

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

或者如果使用 Homebrew Bundler,请添加到您的 Brewfile:

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