3

I am not able to install the pdftk on Amazon Linux AMI release 2012.03. pdftk requires gcj2.14 and amazon ami provides gcj2.12 package. If I try to install gcj2.14 getting conflicts with the existing gcj package. Please suggest a way to install pdftk without any need to upgrade amazon ami linux as my application is already setup and running there.

Your help will be appreciated

cam
  • 4,409
  • 2
  • 24
  • 34
triveni
  • 31
  • 1
  • 3

3 Answers3

15

Inspired by @marcus and his github repo, I just did this:

sudo wget -O /usr/lib64/libgcj.so.10 https://github.com/lob/lambda-pdftk-example/raw/master/bin/libgcj.so.10
sudo wget -O /usr/bin/pdftk https://github.com/lob/lambda-pdftk-example/raw/master/bin/pdftk
chmod a+x /usr/bin/pdftk

Works like a charm.

rouble
  • 16,364
  • 16
  • 107
  • 102
4

As you probably don't want to pollute your production image with all dependencies pdftk requires - one way is to build pdftk somewhere else and deploy it to e.g. through S3.

Following is steps should get you started. Copy and paste from history so should show steps needed.

Pick up RedHat instance from AWS (or local Centos 6)

sudo su -

yum install gcc
yum install gcc-java
yum install gcc-c++

cd /tmp/
wget http://pkgs.repoforge.org/pdftk/pdftk-1.44-2.rf.src.rpm
rpm2cpio pdftk-1.44-2.rf.src.rpm | cpio -idmv
unzip pdftk-1.44-src.zip 

cd pdftk-1.44-dist/
cd pdftk
make -f Makefile.Redhat 
find / -iname libgcj.so.10.0.0
mkdir -p /tmp/pdftk
cp pdftk /tmp/pdftk
find / -iname libgcj.so.10.0.0
cp /usr/lib64/libgcj.so.10.0.0 /tmp/pdftk
cd /tmp/
tar cvzf pdftk.tar.gz pdftk

Make sure you copy tar package content in target machine (Linux AMI) as follows

libgcj.so.10.0.0 install to /usr/lib64

ls -alh /usr/lib64/libgcj.so.*

lrwxrwxrwx 1 root root  27 Sep  6 06:39 /usr/lib64/libgcj.so.10 -> /usr/lib64/libgcj.so.10.0.0

-rwxr-xr-x 1 root root 47M Sep  6 06:38 /usr/lib64/libgcj.so.10.0.0

I just used to S3 bucket to transfer file:

/usr/bin/s3cmd --force get s3://<your-bucket>/rpm/pdftk.tar.gz  /tmp/

pushd /tmp

/bin/tar xzf pdftk.tar.gz  

/bin/cp pdftk/pdftk /usr/bin/

/bin/cp pdftk/libgcj.so.10.0.0 /usr/lib64/libgcj.so.10.0.0

/bin/ln -s /usr/lib64/libgcj.so.10.0.0 /usr/lib64/libgcj.so.10.0

/sbin/ldconfig

popd
nhahtdh
  • 55,989
  • 15
  • 126
  • 162
JariOtranen
  • 126
  • 4
  • Hi, I have formatted your post. Please take a look again to check for discrepancies. Thanks. – nhahtdh Sep 10 '13 at 12:28
  • This mostly works. I've used this to get PDFtk working on AWS Lambda which runs on Amazon Linux. I wrote about it here: https://lob.com/blog/aws-lambda-pdftk/. I've provided the PDFtk binary and GCJ shared library so you can skip the compile step here: https://github.com/lob/lambda-pdftk-example – Marcus Jun 29 '15 at 16:54
1

Very old post, but I've been looking into ways to get pdftk installed on the Amazon distro (which is what the OP is using). Here's a response from an Amazon rep:

GCJ is not supported on the Amazon Linux AMI, which is why you are running into this problem.

In the interest of getting you moving forward as quickly as possible on an EC2 instance that is RPM based, I'd recommend that you give Fedora a try, because pdftk is packaged in their repositories.

Thank you for using EC2, and I hope this suggestion helps you out.

https://forums.aws.amazon.com/thread.jspa?threadID=96919

Alec Sanger
  • 4,442
  • 1
  • 33
  • 53
  • What does this mean? We cannot install pdftk on a EC2 RHEL instance (even though PDF Labs has binary RPM for RHEL)? – Aaron Jan 15 '15 at 17:33
  • You should be able to use it just fine on a RHEL instance - I was trying to get it running on the Amazon Linux distro. – Alec Sanger Jan 15 '15 at 19:07
  • Ok, thanks. How do something like this? http://stackoverflow.com/questions/27969411/installing-pdftk-on-amazon-ec2-rhel-instance – Aaron Jan 15 '15 at 19:13