https://github.com/function61/html2pdf
Small microservice for rendering HTML input to PDF
https://github.com/function61/html2pdf
html2pdf pdf
Last synced: 3 months ago
JSON representation
Small microservice for rendering HTML input to PDF
- Host: GitHub
- URL: https://github.com/function61/html2pdf
- Owner: function61
- License: apache-2.0
- Created: 2016-12-30T15:04:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-23T07:54:20.000Z (over 4 years ago)
- Last Synced: 2025-06-10T14:43:10.346Z (7 months ago)
- Topics: html2pdf, pdf
- Language: Go
- Homepage: https://function61.com/
- Size: 3.7 MB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

What?
-----
A small microservice that turns HTML into a PDF file. You can run this:
- on AWS Lambda
- with Docker
* I didn't bother making a `Dockerfile` though, since I didn't need it. PR welcome!
- as a standalone binary
There also exists [a small client library for Go](pkg/html2pdfclient/)
Security
--------
While we're confident in this project's code, ultimately this is a wrapper to wkhtmltopdf, and thus
you should be aware of its [status](https://wkhtmltopdf.org/status.html#recommendations) and its
security considerations:
- Do not use with untrusted HTML. Only render HTML that you control.
- whtmltopdf uses QtWebKit that hasn’t been updated since 2012
* Qt abandoned QtWebkit in favor or QtWebEngine which uses Chromium internally
Testing
-------
You can start a local server process with:
```console
$ html2pdf server
```
Then call it from the client:
```console
$ export HTML2PDF_TOKEN="doesntMatter" # optionally you can put the service behind authentication
$ html2pdf client-localhost '
hello world
' > out.pdf
```
Usage from curl is also simple:
```console
$ curl -d '{"html_base64": "PGgxPmhlbGxvIHdvcmxkPC9oMT4="}' http://localhost/render > out.pdf
```
Prerequisites for dev/testing
-----------------------------
```console
$ apt install -y libxrender1 libxext6 libfontconfig1
```
(Fortunately, these exist in Lambda's AMI)
Alternatives
------------
- https://weasyprint.org/ (Python, self-implemented rendering)
- https://github.com/shouldbee/docker-html2pdf (go, wkhtmltox)
- https://github.com/carlescliment/html2pdf-service (PHP, wkhtmltopdf)
- https://github.com/spipu/html2pdf (PHP, self-implemented HTML rendering)
Support / contact
-----------------
Basic support (no guarantees) for issues / feature requests via GitHub issues.
Paid support is available via [function61.com/consulting](https://function61.com/consulting/)
Contact options (email, Twitter etc.) at [function61.com](https://function61.com/)