A serverless lambda function to fill a fillable pdf with json data and store the resulting pdf on S3.
- AWS account with AWS-CLI configured and access to S3
- Serverless framework installed
- Fillable PDF (To create a fillable pdf, try pdfescape)
- Clone the repo and install
pdffiller-stream
npm install --save pdffiller-stream
- Add a source fillable pdf in the root directory of the project and change the
sourcePDF
value to that pdf name.
const sourcePDF = "test.pdf";
- Add the required data to be filled in the pdf.
const data = {
"name": "test name",
"date": "dd/mm/yyyy"
};
In most cases, this data will be sent in the event
object while triggering the lambda.
- Update the S3 bucket name and the key of new pdf to be generated.
const Bucket = "bucket"; // Create a bucket or use an existing one in S3.
const Key = "key"; // Name of the generated document
- Update the aws credentials. Access key and access secret key can be taken from the IAM console.
serverless invoke local —f pdftk
serverless deploy