Skip to content

akki-io/html2pdf

Repository files navigation

Hero

html2pdf microservice

html2pdf is a small microservice build using the lumen framework. It utilizes wkhtmltopdf for generating pdfs.

The microservice comes as a docker image, and it can be hosted on services that support docker images. The demo is serverless and run on Google Cloud Run.

Run on Google Cloud

Demo

  1. Preview PDF from HTML - Click Here
  2. Preview PDF from URL - Click Here
  3. Download PDF from HTML - Click Here
  4. Download PDF from URL - Click Here

Run Locally using Docker

  1. Run the docker image docker run -it -rm -p 9091:80 gcr.io/akki-ca/html2pdf
  2. Visit localhost:9091/status

Add the service to your docker-compose.yml file

You can also add the service to your docker-composer file.

    html2pdf:
        image: gcr.io/akki-ca/html2pdf
        ports:
            - "9091:80"

API Documentation

Status

Get the status of the microservice

GET /status

Response

{
    "message": "Request successfully completed."
}

Convert HTML or URL to PDF

GET|POST /

Params

Name Type Nullable Description
url url Y The url that needs to be converted to pdf.
html string Y/N It is required if url is null or not present.
options array Y wkhtmltopdf options - ref here
preview boolean Y If set to 1 you will return a preview of the generated pdf
filename string Y Set the filename of the pdf that will be downloaded

Response

If the request is successful the response will return a preview of the pdf file or as a download depending on the request parameters.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@akki.io instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

References