This docker container lets you run wkhtmltopdf in a docker container.
docker build .
docker run -v $(pwd):/tmp sbitio/wkhtmltox https://sbit.io /tmp/output.pdf
# For wkhtmltoimage:
docker run -v $(pwd):/tmp --entrypoint wkhtmltoimage sbitio/wkhtmltox https://sbit.io /tmp/output.png
The mounted volume can be used to send local html files and to save the output.
We leverage gogap/go-wkhtmltox to provide an as-a-service container on tag aas-latest:
docker run -d --rm --name wkhtmltox sbitio/wkhtmltox:aas-latest
curl -s -X POST \
"http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' wkhtmltox):8080/v1/convert" \
-H 'accept-encoding: gzip' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"to" : "image",
"converter":{
"uri": "https://sbit.io"
},
"template": "binary"
}' --compressed -o sbit.jpg
docker stop wkhtmltox
This image was built at sbit.io.