/aws-lambda-html-pdf

An easy to deploy implementation of html-pdf for AWS Lambda

Primary LanguageJavaScript

aws-lambda-html-pdf

An easy to deploy implementation of the html-pdf package for AWS Lambda

Use case

You need to create a PDF from a HTML string, save the generated PDF file to AWS S3 and return the URL of the file so you can download it or do whatever you need with it. All of this using an AWS Lambda function.

Installation and usage

  • Clone this repo.
  • Run npm install to get all the package dependencies.
  • (Optional) Go to ./node_modules/phantomjs-prebuilt/lib/phantom/bin/ and delete the binary file generated by your OS (you won't need this as you'll use a Linux generated binary). This will reduce the size of your zip file.
  • Remember to change the name of your S3 bucket on the S3config variable
  • Zip everything and upload that to your AWS Lambda function.

Helpful links

This repo was built from different sources and these links could help you.

Future features

Feel free to fork this repo and contribute

  • Return CORS headers for Amazon API Gateway
  • Convert AWS S3 HTML files to PDF
  • Convert any given URL to PDF