Skip to content

Laravel API micro-service which to converts HTML to PDF.

License

Notifications You must be signed in to change notification settings

NdoleStudio/dompdf-api

Repository files navigation

dompdf API

Build GitHub contributors GitHub license

This project provides an HTTP API wrapper around the dompdf library which converts HTML to PDF. The API is created using the Laravel framework, and you can protect the API using the basic HTTP authentication scheme.

Docker Setup

Run the docker container using the command below

docker run -p 8000:80 ndolestudio/dompdf-api

Make an HTTP request to convert an HTML string into a PDF file called document.pdf

curl -X POST -d '<h1>Hello World</h1>' http://localhost:8000 --output document.pdf

Authentication

If you want to protect the API with basic auth, you can set the AUTH_USERNAME and AUTH_PASSWORD environment variables when running the docker container

docker run -p 8000:80 \
      --env AUTH_USERNAME="username" \
      --env AUTH_PASSWORD="password" \
      ndolestudio/dompdf-api

NOTE: You must now set the username and password when making requests to the API

## username:password in base64 is dXNlcm5hbWU6cGFzc3dvcmQ=
curl  -X POST -d '<h1>Hello World</h1>' \
      -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
      http://localhost:8000 --output document.pdf

Security Vulnerabilities

If you discover a security vulnerability within the dompdf-api service, please send an e-mail to Acho Arnold via [email protected]. All security vulnerabilities will be promptly addressed.

License

dompdf-api is an open-sourced software licensed under the MIT license.