• This repository has been archived on 10/Nov/2022
  • Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example project that runs PDFtk in AWS Lambda

AWS Lambda + PDFtk Example

This repository provides a working example of using PDFtk within AWS Lambda. AWS Lambda runs on Amazon Linux, which does not officially support PDFtk or GCJ, one of PDFtk's dependencies. This example works by including both a PDFtk binary and the libgcj shared library.

Run the Example

To run the example, first package up the project into a ZIP file by running:

./dist.sh

Then, simply upload this ZIP to AWS Lambda. When testing with the Lambda web interface, you should see the function succeed and output PDFtk's version and copyright information.

You can very easily expand on this boilerplate and use PDFtk in the way it was intended for - manipulating PDF files.

How it Works

AWS Lambda supports binary dependencies by allowing them to be included in uploaded ZIP files. However, because Amazon Linux does not support PDFtk or GCJ, PDFtk was built from source in CentOS, a close relative of Amazon Linux. I spun up a CentOS 6 machine in EC2 and followed the instructions on the PDFtk website to build PDFtk from source.

sudo yum install gcc gcc-java libgcj libgcj-devel gcc-c++

wget https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-src.zip

unzip pdftk-2.02-src.zip

cd pdftk-2.02-dist/pdftk

make -f Makefile.Redhat

sudo make -f Makefile.Redhat install

Then I copied the resulting pdftk binary and /usr/lib64/libgcj.so.10 shared library into the bin/ directory of my Lambda project.

The entry point to the lambda function, index.js, alters the PATH and LD_LIBRARY_PATH environment variables to let the system know where to find the binary and the GCJ dependency.

Using PDFtk in Amazon Linux

It should be possible to use the PDFtk binary and GCJ shared library located in the bin/ directory of this file to run PDFtk in Amazon Linux on EC2. Simply copy them onto the machine and put them in the correct path, or call them directly:

LD_LIBRARY_PATH=/path/to/libgcj.so.10 /path/to/pdftk --version

More Repositories

1

generate-changelog

Generate a changelog from git commits.
JavaScript
543
star
2

pg_insights

A collection of convenient SQL for monitoring Postgres database health.
TSQL
299
star
3

lob-ruby

Ruby Wrapper for Lob API
Ruby
97
star
4

lob-node

Node.js Wrapper for Lob API
JavaScript
84
star
5

lob-python

Python Wrapper for Lob API
Python
79
star
6

lob-php

PHP Client for Lob API
PHP
67
star
7

hapi-bookshelf-models

NO LONGER SUPPORTED
JavaScript
35
star
8

litmus

Data schema validation in Elixir
Elixir
34
star
9

examples

HTML Examples for use with Lob Print & Mail APIs
HTML
22
star
10

intern-interviews

HTML
21
star
11

lob-java

Java Wrapper for Lob API
Java
19
star
12

ui-components

Lob's Vue component library
Vue
17
star
13

hapi-rate-limiter

JavaScript
16
star
14

lob-elixir

Elixir Library for Lob API
Elixir
15
star
15

aws-creds

CLI tool to authenticate with Okta as the IdP to fetch AWS credentials
Go
12
star
16

lob-typescript-sdk

TypeScript
10
star
17

lob-openapi

OpenAPI v3 spec for Lob API
JavaScript
8
star
18

nomad-autoscaler-cloudwatch-apm

Nomad Autoscaler APM Plugin for AWS Cloudwatch
Go
7
star
19

react-address-autocomplete

React Autocomplete component for Lob Address Autocomplete
JavaScript
6
star
20

usps-webtools-api

Open source documentation for USPS Web Tools API
JavaScript
6
star
21

pdffonts

Node bindings for Poppler's pdffonts CLI
JavaScript
4
star
22

lob-address-elements

A JavaScript library that adds address autocompletion and verification to a standard HTML Web form.
JavaScript
4
star
23

medusa-next-address-autocomplete

Next starter project for MedusaJS and Lob Address Autocomplete
JavaScript
3
star
24

action_sam_jackson

Respond to comments/issues with a message and a gif of Samuel L. Jackson
JavaScript
3
star
25

fluent-plugin-json-transform

A plugin for doing arbitrary transformation on input JSON.
Ruby
3
star
26

address-elements

JavaScript
3
star
27

lob-go

Go wrapper for Lob API
Go
3
star
28

hapi-bookshelf-total-count

Hapi plugin used with Bookshelf models to calculate the total number of records that match a query and appends it to the response
JavaScript
3
star
29

react-lob-address-autocomplete

JavaScript
1
star
30

vue-address-autocomplete

JavaScript
1
star
31

pdf-wrapper-template

A template for the pdf-wrapper interview question
TypeScript
1
star
32

lob-node-examples

JavaScript
1
star
33

typed

CLI tool for typescript tasks & migrations
Python
1
star
34

lob-dotnet

.NET Wrapper for Lob API
C#
1
star