Adding pdftk to 1and1 shared hosting

UPDATE 2010-09-03: I updated a couple links to reflect newer downloads. Because 1and1 shared hosting is on an older debian (etch) system I had to tweak the steps for using lenny based packages. ENJOY!

There are some cases where you might need a powerful pdf toolkit to use with php. 1and1 does not come with any built in pdf processors or pdf libraries built into php. Here is the process I used to integrate phptk into my 1and1 shared hosting account.

Requirements: 1and1 shared plan that has ssh support

– Download pdftk deb file for debian lenny:

wget http://ftp.us.debian.org/debian/pool/main/p/pdftk/pdftk_1.41-3_i386.deb

– Extract the pdftk deb file:

ar xv pdftk_1.41-3_i386.deb

– Extract the data.tar.gz file:

tar xvzf data.tar.gz

– Download libgcj deb file for debian lenny:

wget http://ftp.us.debian.org/debian/pool/main/g/gcj-4.2/libgcj8-1_4.2.4-4_i386.deb

– Extract the libgcj deb file:

ar xv libgcj7-0_4.1.1-20_i386.deb

– Extract the data.tar.gz file:

tar xvzf data.tar.gz

– Download libstdc++ deb file for debian lenny (backport file http://packages.debian.org/lenny-backports/i386/libstdc++6/download):

wget http://mirror.linux.org.au/backports.org/pool/main/g/gcc-4.3/libstdc++6_4.3.4-6~bpo50+1_i386.deb

– Extract the libstdc++6 deb file:

ar xv libstdc++6_4.3.4-6~bpo50+1_i386.deb

– Extract the data.tar.gz file:

tar xvzf data.tar.gz

– Create a script to link libgcj and libstdc++6 for pdftk (use nano or vi):

#!/bin/bash

LD_LIBRARY_PATH="usr/lib:$LD_LIBRARY_PATH" usr/bin/pdftk $*

– Chmod the pdftk script so it can run:

chmod 755 pdftk

Now you can run pdftk from your main directory and process files from php or cronjobs.

If you run into any problems try running the pdftk command with some test files. If you have any problems please leave a comment. Thanks!