This project contains the implementation for a HTTP endpoint which performs 2 useful functions involving the conversion of:
- HTML string to PDF
- HTML string to a thumbnail (base64)
- img url string to an img (smaller)
Below are the access details for each API endpoint
POST "https://{HOST}/pdf/generate"
body = {
"html": "<html><div>Hello World</div></html>",
"filename": "hello_world.pdf",
"imageResolution": "150"
}
POST "https://{HOST}/html/base64thumb"
body = {
"html": "<html><div>Hello World</div></html>",
"filename": "hello_world",
"type": "png",
"width": "100",
"height": "100"
}
GET "https://{HOST}/img/urlshrink"
query = {
"url": "https://example.com/image.png",
"widthmax": 500
}
This uses a node webserver, which is contained within a Docker image. This can be deployed with little configuration changes to many different platforms.
yarn build && docker build -t pdf-server .
docker run -ti -p 8080:8080 pdf-server
./deploy.sh