How do I install Pdftk on my server?

吃可爱长大的小学妹 提交于 2019-11-29 09:24:23

问题


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?


回答1:


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.

ssh [server to install pdftk on]

Now that we are in the server we need to create the directories to store pdftk.

cd /
sudo mkdir extra
cd extra
sudo mkdir src
cd src
sudo wget http://www.pdfhacks.com/pdftk/pdftk-1.41.tar.gz
sudo tar zxvf pdftk-1.41.tar.gz
cd pdftk-1.41/pdftk

Now we need to install the gcj libraries.

sudo yum install java-1.4.2-gcj-compat-devel.i386

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.

sudo yum install gcc-c++

If you compile the application right now you will receive a warning that tmpnam is dangerous to use and you should use mkstemp.

sudo vi report.cc

Run this from inside VI to do a search and replace for the tmpnam method.

:%s/tmpnam(/mkstemp(/g

Press escape and save the changes with

:wq!

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

sudo make -f Makefile.RedHat

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.

sudo cp pdftk /usr/local/bin

Let's make sure the build was successful and run

pdftk --version


来源:https://stackoverflow.com/questions/3146766/how-do-i-install-pdftk-on-my-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!