0

I was given a .zip file that had an external library called Python PDF Toolkit, often abbreviated as pdftk or pypdftk.

To my current knowledge, this external dependency was built on a EC2 instance of CentOS6, because the pdftk has its own dependency called libgcj.

enter image description here

As you can see from the image, most of the files are Unix Executable Files, and are missing their file extensions.

  1. Will this create problems in Lambda? I believe the pdftk needs to be uploaded as a Lambda Layer to help extend the standard core Python Library.

  2. If this will create problems executing Lambda, are there any steps I can take to find the file extensions?

Lastly, I can edit this question and add the code within these files if you believe that will help.

WHEEL

Wheel-Version: 1.0
Generator: bdist_wheel (0.35.1)
Root-Is-Purelib: true
Tag: py2-none-any

It looks like this won't work with Py3?

Stephen Stilwell
  • 518
  • 1
  • 5
  • 17

1 Answers1

1

pypdftk is a wrapper for pdftk binary. So you need 2 things:

  1. Install the pdftk binary as a Lambda Layer. For more details look here.
  2. You also need the python code. It seems that this is only a python file. You can either copy it directly or your code or install it with pip. It should work with python 3.

You have been provided with a wheel package. Chances are that it won't work with lambda and python 3, although it isn't impossible to properly configure everything. It should be easier to install pypdftk and binary dependencies from scratch.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
  • from the official build guide: https://www.pdflabs.com/docs/install-pdftk-on-redhat-or-centos/ it they suggest using CentOS 6, but this reached End of Life (EOL) in 2020. Should I do this on CentOS6 even if its EOL? or try working with latest releases? – Stephen Stilwell Nov 22 '21 at 21:16
  • I would first try the pre-built binaries in the github project (https://github.com/inetsys/pdftk-aws-lambda). Binaries were built in CentOS6. I would then try to build it in Amazon Linux 2. This may be more difficult. – kgiannakakis Nov 22 '21 at 21:24
  • Ok. I was able to build the binaries using GitHub project and upload them as a lambda layer. I will accept your answer, but I am still getting `Runtime.ImportModuleError: Unable to import module` – Stephen Stilwell Nov 22 '21 at 21:45
  • Check that everything is uploaded correctly and that the name of your handler is correct. Check https://stackoverflow.com/questions/35340921/aws-lambda-import-module-error-in-python – kgiannakakis Nov 23 '21 at 06:28