Sign inSign up

xjodoin/htmlpdfconverter

By xjodoin

•Updated over 5 years ago

Image
0

1.2K

xjodoin/htmlpdfconverter repository overview

⁠HTML to PDF Microservice

Web page PDF rendering done right. Microservice for rendering receipts, invoices, or any content.

Features:

  • Web interface to generate PDF render
  • Converts any URL or HTML content to a PDF file
  • Rendered with Headless Chrome, using Puppeteer⁠. The PDFs should match to the ones generated with a desktop Chrome.
  • Single-page app (SPA) support. Waits until all network requests are finished before rendering.
  • Easy deployment to Kubernetes or any docker runtime.

Usage is as simple as https://htlmpdfconverter.com?url=https://google.com⁠. There's also a POST /api/render if you prefer to send options in the body.

Why?

This microservice is useful when you need to automatically produce PDF files for whatever reason. The files could be receipts, weekly reports, invoices, or any content.

PDFs can be generated in many ways, but one of them is to convert HTML+CSS content to a PDF. This API does just that.

⁠Good to know
  • By default, page's @media print CSS rules are ignored. We set Chrome to emulate @media screen to make the default PDFs look more like actual sites.

  • Chrome is launched with --no-sandbox --disable-setuid-sandbox flags to fix usage in Heroku. See this issue⁠.

  • Heavy pages may cause Chrome to crash if the server doesn't have enough RAM.

  • Docker image for this can be found here: https://hub.docker.com/repository/docker/xjodoin/htmlpdfconverter⁠

⁠Examples

Try it online⁠

⁠Licensing

htmlpdfconverter is licensed under the Apache License, Version 2.0. See LICENSE⁠ for the full license text.

Tag summary

Content type

Image

Digest

Size

290.8 MB

Last updated

over 5 years ago

docker pull xjodoin/htmlpdfconverter