https://github.com/modfin/betterpress
html to pdf microservice
https://github.com/modfin/betterpress
Last synced: 11 months ago
JSON representation
html to pdf microservice
- Host: GitHub
- URL: https://github.com/modfin/betterpress
- Owner: modfin
- License: mit
- Created: 2019-05-23T13:35:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-15T12:21:20.000Z (over 2 years ago)
- Last Synced: 2025-04-08T10:23:47.285Z (about 1 year ago)
- Language: Java
- Homepage: https://hub.docker.com/r/modfin/betterpress
- Size: 17.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Betterpress
Betterpress wraps [openhtmltopdf](https://github.com/danfickle/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:
```bash
docker run -p 7357:8080 modfin/betterpress
```
1. 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--
```
:information_source: tip - don't write this by hand, use a http library :)
1. Betterpress will reply with the generated pdf file
### Notes
Betterpress always uses `W3CDom().fromJsoup(indexDoc)` mentioned in [the openhtmltopdf integration guide](https://github.com/danfickle/openhtmltopdf/wiki/Integration-Guide#html5-parser-support). 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`.
### Dev
Release new versions of the docker image unto [dockerhub](https://hub.docker.com/r/modfin/betterpress):
```bash
docker login --username=yourhubusername # then enter pass
./docker-build-push.sh
```