This service exposes an HTTP endpoint for uploading html mustache documents and receiving a PDF file attachment response.
- Must include dynamic templates (user should be able to choose template)
- Should be able to update template without having to update software
- Must be able to specify a header and footer
- Must be able to include images
- Must be able to include CSS styling
This tool uses the Pydf library to generate a pdf
This tool uses Flask to serve the http endpoint
-
Clone the application:
> git clone [email protected]:CodeBiosys/pdf-microservice > cd pdf-microservice
-
Provision a new Docker machine called
pdf-microservice
:> docker-machine create -d virtualbox pdf-microservice > eval $(docker-machine env pdf-microservice) > docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS pdf-microservice * virtualbox Running tcp://192.168.99.102:2376 v18.06.0-ce
Note the asterisk in the "ACTIVE" column.
-
Build the application stack and start the services:
> docker-compose up -d --build
-
Once the application begins, the build process is complete you can post the following via http to http://{docker-machine-ip}:8000/
Parameter Required Type Description template Yes HTML or ZIP An HTML template file or bundle of assets to use params No JSON Paramters to pass to the Mustache template config No JSON Weasyprint configuration The application will respond with a pdf stream of the resulting pdf.
> mkvirtualenv pydf-microservice
> git clone https://github.com/Codebiosys/pdf-microservice.git
> cd pdf-microservice
> pip install -r requirements-develop.txt
> pip install -e .
> pytest -vv
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.