Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sleavely/pdf-lambda
HTML-to-PDF API with Handlebars support, hosted on AWS Lambda
https://github.com/sleavely/pdf-lambda
aws-lambda cloudformation handlebars pdf-generation puppeteer
Last synced: 25 days ago
JSON representation
HTML-to-PDF API with Handlebars support, hosted on AWS Lambda
- Host: GitHub
- URL: https://github.com/sleavely/pdf-lambda
- Owner: Sleavely
- License: mit
- Created: 2021-11-17T16:13:26.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-02T19:01:48.000Z (about 2 years ago)
- Last Synced: 2024-11-13T08:38:15.224Z (3 months ago)
- Topics: aws-lambda, cloudformation, handlebars, pdf-generation, puppeteer
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pdf-lambda
An AWS Lambda that renders PDFs from HTML templates with the help of [`Handlebars`](https://handlebarsjs.com/) and [`puppeteer`](https://github.com/GoogleChrome/puppeteer).
## Setup
Deploy the Cloudformation stack to AWS:
```shell
make deploy
```This will create an API gateway and an S3 bucket for your PDFs.
## Usage
The API exposes a single POST endpoint:
### `/pdf-lambda`
**Parameters**
- `url` - The URL to use as a template.
- `data` - A JSON object to feed Handlebars**Description**
Request a render from the API endpoint:
```
curl \
-X POST \
-H "Content-Type: application/json" \
https://your-api-gateway-hostname/pdf-lambda \
-d '{
"url": "https://docs.google.com/document/d/e/2PACX-1vRsOF1-sr6U5ONvX6rvk3SYJII2Qf3SlCyj-DD1gNYpH7h3D1ut-rXd_kjphC0Fs9_GsCTAM5Xl8vrH/pub",
"data": {
"name": "Sleavely",
"experiences": [
{ "company": "Stark Industries", "title": "Tech Lead", "description": "Making tiny iron people." },
{ "company": "Wayne Enterprises", "title": "Security Officer", "description": "Security officer by day, millionaire by night."},
{ "company": "Los Pollos Hermanos", "title": "Clerk", "description": "I took a sabbatical to fry some chicken. Learned a lot about chemistry."},
{ "company": "Gringotts", "title": "Financial Advisor", "description": "Improved securiy with KMS"}
]
}
}'
```The API will return an S3 URL for the rendered PDF.
Here's a before- & after- using the cURL from earlier:
![](https://i.imgur.com/kC7627v.png)