Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Serverless API that converts HTML pages to PDF documents

License

NotificationsYou must be signed in to change notification settings

kdcio/serverless-html-to-pdf

Repository files navigation

This creates an API (AWS API Gateway and lambda) that converts HTML pages to PDF documents usingwkhtmltopdf (0.12.4). It implements a simple interface to read an HTML input and output PDF content.

This project is a fork ofzeplin/zeplin-html-to-pdf.

GitHub release (latest by date)GitHub Workflow Status

Setup

git clone https://github.com/kdcio/serverless-html-to-pdf.gitcd serverless-html-to-pdfnpm install

Run in local environment

Requires docker to simulate lambda environment.

npm start

Usage

API POST

POST http://localhost:3000Content-Type: application/json{"html":"<!DOCTYPE html><html><head><title>HTML doc</title></head><body>Content</body></html>"}

Seetests/api.http to try. You'll need to open this project onVS Code withREST Client extension for it to work.

API Output

It yields a response in the following format:

{"data":"JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."}

data is base64 encoding of the converted PDF file.

Example

Run example API client code inexample/client.js:

npm run client

This will generatebase64.pdf file.

Deploying to AWS

Deploy using yourdefault AWS profile inap-southeast-1 region andAsia/Manila timezone.

npm run deploy

Customize the parameters by creating a config for your stage. For example, create the fileconfig.prod.yml in the project root with the contents below.

REGION:us-east-1PROFILE:productionTZ:America/New_York

To use that config file, run the command below:

npm run deploy prod

Star Me

If you find this project useful, please consider giving a star. I would really appreciate it.

You can also:

Buy Me A Coffee

License

MIT

About

Serverless API that converts HTML pages to PDF documents

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp