Sign inSign up

modfin/betterpress

By modfin

•Updated 6 months ago

html to pdf microservice

Image
1

7.0K

modfin/betterpress repository overview

⁠Betterpress

Betterpress wraps openhtmltopdf⁠ in a Spark server inside a docker container. This makes for a convenient pdf generation service over http.

⁠User Guide
  1. Download/run the docker image:

    docker run -p 7357:8080 modfin/betterpress
    
  2. Send files over http as multipart form data where the index file/entry point must have name property index.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 :)

  3. Betterpress will reply with the generated pdf file

⁠Notes

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.

⁠Github

https://github.com/modfin/betterpress⁠

Tag summary

Content type

Image

Digest

sha256:694f6459e…

Size

204 MB

Last updated

6 months ago

docker pull modfin/betterpress