How to install PDFtk on an AWS Elastic Beanstalk environment


If you need help installing PDFtk on an ElasticBeanstalk instance, this post will help you out. Although EB is an awesome service when it comes deploying, provisioning, load-balancing and scaling applications, installing additional packages can be a little tricky from time to time.

Recently, we wanted to create a worker environment, that receives JSON messages from an SQS queue, creates a PDF file and uploads it to S3, but it turned out installing PDFtk isn't very straightforward so here's how to do it if you're in the same sitch.


EB (ElasticBeanstalk) environments can be customized through YML configuration files, you can read more here. The first thing you need to do would be to create an empty folder within the root directory of your projects, named .ebextensions - that's where the configuration files will go. EB will see this folder upon deployment and execute the configurations inside. Once you have that, you need to add 3 configuration files (these can be organized differently, EB doesn't care how the commands are split) that would install the necessary libraries and PDFtk itself:



Step 1 - Text LIve


The first step would be to install the Tex Live packages. You do that by creating a 00_packages.config (again, filename doesn't matter, just keep in mind EB executes configuration files top to bottom) and adding the following content:





Step 2 - libgcj


Once you have that, you need to install the libgcj package, which PDFtk uses, but since that doesn't ship with the OS, you need to add the following configuration file:



This will make libgcj available for install in the next step.




Step 3 - PDFtk, PDFJam


The next (last) configuration file will install libgcj, PDFtk, PDFJam:





Step 4 - Deploy


Once you've added the three configuration files to your .ebextensions folder, all you'll have to do is deploy your application and that's all of it. Don't hesitate to let us know if this guide doesn't work for you and we can try to help you out.

Need help?

Book a 1h session with an expert on this very matter

€75/h

Pair programming

Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator,[1] reviews each line of code as it is typed in. The two programmers switch roles frequently.