如何在我的服务器上安装 Pdftk?
我正在使用 Linux 服务器并尝试安装 Pdftk,但我在尝试弄清楚到底要做什么时遇到问题。
我找到了以下有关如何安装它的文档,但它们主要指的是在本地 Windows 计算机上安装它。
他们是: http://www.andrewheiss.com/blog/2009/ 07/29/installing-pdftk-php/
http://www.accesspdf.com/ pdftk/#packages
有人可以帮助我准确理解我需要将哪些文件放置在服务器上的位置,以便我可以参考 pdftk 吗?
I am using a Linux Server and am trying to install Pdftk, but I am problems trying to figure out what exactly to do.
I found the following documentation on how to install it, but they refer mostly to installing it on the local Windows machine.
They are:
http://www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/
http://www.accesspdf.com/pdftk/#packages
Can someone help me unserstand exactly what files I need to place where on my server so I can refer to pdftk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Pdftk 是 iText 的一个版本,已从 Java 转换为 C++,并使用命令行桥重新构建,以便从 PHP 应用程序轻松访问。
要在 Redhat / CentOS 上构建 pdftk,请按照以下说明操作。
现在我们位于服务器中,我们需要创建目录来存储 pdftk。
现在我们需要安装 gcj 库。
gcc-c++ 库没有随 gcj 包一起安装,因此我们现在就安装它,这样我们就不会在编译过程中途出现错误。
如果您现在编译应用程序,您将收到一条警告,指出使用 tmpnam 存在危险,您应该使用 mkstemp。
从 VI 内部运行此命令来搜索并替换 tmpnam 方法。
按 escape 并保存更改
现在我们已经安装了所有软件包,我们将开始
从 /extra/src/pdftk-1.41/pdftk 编译 pdftk-1.41 运行以下命令
这将启动编译和构建过程将java文件转换为c++文件。将 iText 转换为 c++ 可能需要几分钟的时间。去休息室从我们的新玛格丽塔机里拿一杯玛格丽塔吧:)。
现在创建 pdftk 文件后,我们希望将其复制到 /bin 目录,以便我们可以从任何地方运行它。
让我们确保构建成功并运行
Pdftk is a version of iText which has been converted from Java to c++ and rebuilt with a command-line bridge for easy access from PHP applications.
To build pdftk on Redhat / CentOS please follow the below instructions.
Now that we are in the server we need to create the directories to store pdftk.
Now we need to install the gcj libraries.
The gcc-c++ library doesn't get installed with the gcj package so we will install it now, so we don't get an error halfway through the compile process.
If you compile the application right now you will receive a warning that tmpnam is dangerous to use and you should use mkstemp.
Run this from inside VI to do a search and replace for the tmpnam method.
Press escape and save the changes with
Now that we have all the packages installed, we are going to start compiling pdftk-1.41
from /extra/src/pdftk-1.41/pdftk run the following command
This will kick off the build process for compiling and converting the java file to c++. This could take SEVERAL minutes to convert iText to c++. Go grab yourself a margarita from our new margarita machine in the break room :).
Now with the pdftk file created we will want to copy it to the /bin directory so that we can run it from anywhere.
Let's make sure the build was successful and run
到了2020年,情况已经不同了。 CentOS 6 即将退出,pdftk 只能支持 CentOS 5/ 6.。 CentOS 7 上的 GCJ 被删除,因此从源安装也不容易。但我们现在有了 docker:
然后使用 docker build 进行构建。 -t pdftk 并运行为:
如果幸运的话,上面的示例可以修复丢失十几 KB 数据的 pdf 文件。
As of 2020, things are different now. CentOS 6 is stepping out and pdftk can only support CentOS 5/6. GCJ on CentOS 7 is removed, so installing from source is not easy too. But we have docker now:
Then build with
docker build . -t pdftk
and run as:The example above can repair a pdf file missing a dozen of KB of data if you are lucky.
正如 @rsc 提到的,pdftk-java 将可用于 Rocky Linux,但目前(2021.10.28)仍然无法通过 yum 安装它。
幸运的是,有一个针对 x86_64 GNU/Linux 系统的内置命令,它不需要任何运行时依赖项。所以我们可以按如下方式使用它
它在具有以下系统信息的服务器中运行良好,
As mentioned by @rsc, pdftk-java will be available for Rocky Linux, but currently (2021.10.28), still cannot install it via
yum
.Fortunately, there is a built command for x86_64 GNU/Linux systems, which does not require any runtime dependencies. So we can use it as follows
It works well in the server with the following system info,
截至 2021 年,有 pdftk-java:原始基于 GCJ 的 PDFtk 的端口Java,目前正在发送到存储库的路上对于 Fedora 33+ 和 EPEL 7+(后者适用于 CentOS、RHEL 或 Rocky),允许 yum install pdftk-java 成功(一旦软件包到达稳定存储库)。
编辑: pdftk-java 包从昨天(2021 年 10 月 29 日)开始就位于稳定存储库中。
As of 2021, there is pdftk-java: A port of the original GCJ-based PDFtk to Java, which is currently on the way to the repositories for Fedora 33+ and EPEL 7+ (latter for CentOS, RHEL or Rocky), allowing
yum install pdftk-java
to succeed (once the package reached the stable repositories).Edit: The pdftk-java package is in the stable repositories since yesterday, 2021-10-29.