Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeplin/zeplin-html-to-pdf
AWS Lambda function that converts HTML pages to PDF documents
https://github.com/zeplin/zeplin-html-to-pdf
aws-lambda html html-to-pdf nodejs pdf pdf-document wkhtmltopdf zeplin
Last synced: 20 days ago
JSON representation
AWS Lambda function that converts HTML pages to PDF documents
- Host: GitHub
- URL: https://github.com/zeplin/zeplin-html-to-pdf
- Owner: zeplin
- License: mit
- Created: 2016-08-09T21:57:20.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-22T06:41:31.000Z (22 days ago)
- Last Synced: 2024-10-23T09:37:40.956Z (21 days ago)
- Topics: aws-lambda, html, html-to-pdf, nodejs, pdf, pdf-document, wkhtmltopdf, zeplin
- Language: JavaScript
- Homepage:
- Size: 16.1 MB
- Stars: 130
- Watchers: 28
- Forks: 54
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Zeplin HTML to PDF Lambda
This is an AWS Lambda function that converts HTML pages to PDF documents using wkhtmltopdf (0.12.4), it implements a simple interface to read and HTML input and output PDF content.
> **WARNING**: You must use v2.x.x tag if you are using Node.js runtime >=10.x in AWS Lambda.
## Input
Input event to this function has the following structure:
```
{
"html": "HTML docContent"
}
```## Output
It yields a response in the following format:
```
{
"data": "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."
}
```
`data` is base64 encoding of the converted PDF file.## Test in local environment
The function can be tested locally using [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html). You can change contents of `events/example-event.json` or you can create a new file which you will give sam as an event parameter.```
sam local invoke "HtmlToPdf" -e events/example-event.json
````## Deploying to AWS
There are two ways in which these functions can be deployed to AWS.1 - Check our `npm run deploy:dev` and `npm run deploy:prod` commands in `package.json` and change it according to your needs. Do not forget to add environment variables (you can find it under `template.yml`) to your lambda function in aws lambda edit page or running [lamba update-function-configuration command](https://docs.aws.amazon.com/cli/latest/reference/lambda/update-function-configuration.html). Be sure to create the following environment variable in Lambda: `FONTCONFIG_PATH=/var/task/fonts`
2 - Check out `template.yml` file and edit according to your needs then use `sam deploy`.