A service that generate pdf from html and css
100K+
This is server side of Pdf service by Paralect service-stack description. It is the simple HTTP server was written on koa which handle POST request: POST /pdf Body of the request should consist of url or html properties.
Note: If you provide two properties. Server will generate pdf by url.
To prevent wkhtmltopdf installing server should be started from docker container.
Build and start the container. To build the image of the server you in root server directory you should run:
docker build ./
After that the docker image will be built. On the next step you should start the container. For example, to start the image on 3000 port you can run:
docker run -d -p 3000:3000 9519024e532d
Also image exposes only 3000 port, so you should use this port when you map ports.
Image can be loaded from Docker Hub (docker pull paralect/pdf-service). Here is the sample of using with docker-compose
version: '2'
services:
pdf-service:
image: paralect/pdf-service
ports:
- "4444:3000"
If you place this code to docker-compose.yml file then you are able to run it by command:
docker-compose up -d
This request can have a html text and special wkhtmltopdf options (look options sections here)in body. The sample of request to localhost with Fetch API:
fetch('http://localhost:3000/pdf', {
method: 'POST',
body: JSON.stringify({
wkhtmltopdfOptions,
html,
}),
headers: {
'Content-Type': 'application/json',
},
responseType: 'blob',
});
Or if you want to generate pdf by url.
fetch('http://localhost:3000/pdf', {
method: 'POST',
body: JSON.stringify({
wkhtmltopdfOptions,
"url": "https://google.com",
}),
headers: {
'Content-Type': 'application/json',
},
responseType: 'blob',
});
If you provide output option the empty html will be generated (also it is related to other options).
Content type
Image
Digest
Size
530.4 MB
Last updated
almost 6 years ago
docker pull paralect/pdf-service