Betterpress wraps openhtmltopdf in a Spark server inside a docker container. This makes for a convenient pdf generation service over http.
-
Download/run the docker image:
docker run -p 7357:8080 modfin/betterpress
-
Send files over http as multipart form data where the index file/entry point must have
name
propertyindex.html
. This looks something like the following:POST / User-Agent: myagent Accept: */* Host: localhost:7357 accept-encoding: gzip, deflate content-type: multipart/form-data; boundary=myboundary content-length: 192668 --myboundary Content-Disposition: form-data; name="index.html"; filename="myindexfile.html" [index.html binary] --myboundary Content-Disposition: form-data; name="styles.css"; filename="styles.css" [styles.css binary] --myboundary Content-Disposition: form-data; name="font.ttf"; filename="font.ttf" [font.ttf binary] --myboundary--
ℹ️ tip - don't write this by hand, use a http library :)
-
Betterpress will reply with the generated pdf file
Betterpress always uses W3CDom().fromJsoup(indexDoc)
mentioned in the openhtmltopdf integration guide. I.e. make sure to send index.html
in html5 format. Note that css2.1 still is a limit so e.g. for fonts we must use @font-face
instead of @import
.
Release new versions of the docker image unto dockerhub:
docker login --username=yourhubusername # then enter pass
./docker-build-push.sh