node-pdftk + serverless Real world example
yarn
npm install -g serverless
You can easily test in local environment thanks to serverless-offline plugin.
sls offline
It starts local server on http://localhost:3000. There are two endpoints /stamp
, and /merge
.
Note that you should use input
, stamp
for key name.
It stamps stamp
PDF on input
PDF, but only first page. You can change the function in stamp.js
.
It returns PDF blob with application/pdf
header so you can check out the preview in response body in Postman.
It merges all incoming PDF regardless of key name. Note that the page order is output as a result of sorting the keys in the file in ascending order.
It returns PDF blob with application/pdf
header so you can check out the preview in response body in Postman.
provider:
name: aws
runtime: nodejs12.x
stage: production
region: ap-northeast-2
Update the region
, stage
, etc to meet your needs.
layers:
- arn:aws:lambda:ap-northeast-2:545918303703:layer:pdftkLayer:3
You can use my prebuilt lambda layer (pdftk v2.02
) or use your own layer.
sls deploy --stage=production