项目作者: function61

项目描述 :
Small microservice for rendering HTML input to PDF
高级语言: Go
项目地址: git://github.com/function61/html2pdf.git
创建时间: 2016-12-30T15:04:14Z
项目社区:https://github.com/function61/html2pdf

开源协议:Apache License 2.0

下载


Build status

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

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 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:

  1. $ html2pdf server

Then call it from the client:

  1. $ export HTML2PDF_TOKEN="doesntMatter" # optionally you can put the service behind authentication
  2. $ html2pdf client-localhost '<h1>hello world</h1>' > out.pdf

Usage from curl is also simple:

  1. $ curl -d '{"html_base64": "PGgxPmhlbGxvIHdvcmxkPC9oMT4="}' http://localhost/render > out.pdf

Prerequisites for dev/testing

  1. $ apt install -y libxrender1 libxext6 libfontconfig1

(Fortunately, these exist in Lambda’s AMI)

Alternatives

Support / contact

Basic support (no guarantees) for issues / feature requests via GitHub issues.

Paid support is available via function61.com/consulting

Contact options (email, Twitter etc.) at function61.com