https://github.com/doist/pdfsvc
html to pdf conversion service
https://github.com/doist/pdfsvc
Last synced: about 1 year ago
JSON representation
html to pdf conversion service
- Host: GitHub
- URL: https://github.com/doist/pdfsvc
- Owner: Doist
- License: mit
- Archived: true
- Created: 2017-09-14T17:25:21.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T12:06:55.000Z (almost 3 years ago)
- Last Synced: 2025-03-21T21:44:27.588Z (over 1 year ago)
- Language: Go
- Size: 5.15 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Command pdfsvc is a small wrapper around [WeasyPrint command][1] to expose it as
a http service.
[1]: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#command-line
Service accepts POST requests expecting html bodies and proper `Content-Type:
text/html` header. If html is not utf8, either set proper encoding in
`Content-Type` header or directly in html. If html is successfully converted,
reply would have code 200 OK and `Content-Type: application/pdf`, the body
would be a pdf document.
If pdfsvc is started with `TOKEN` environment variable or `-token=value` flag,
only requests having `Authorization: Bearer token` header are allowed.
You can build ready-to-use docker image using Dockerfile from this repository
(Docker 17.05 or later is required):
docker build -t pdfsvc:latest .
Then run it:
docker run -p 8080:8080 --rm pdfsvc
You can use `ADDR` environment variable to change address service listens at
and `TOKEN` to enable request authentication.
Example of calling service listening on localhost:8080 with curl:
curl -sD- -o output.pdf -T input.html \
-X POST -H "Content-Type: text/html" http://localhost:8080/