Public | Automated Build

Last pushed: 5 months ago
Short Description
Microservice that handles pdfkit (wich uses wkhtmltopdf) for easy PDF generation.
Full Description

PDF Generator Flask microservice



This is a microservices that handles pdfkit wich uses wkhtmltopdf and makes it a microservice
to make it easy the PDF generation.

Docker hub installation

docker run -d --name wkhtmltopdf-aas -p <hostport>:80 ciricihq/wkhtmltopdf-aas

Builds are automatically generated from github. So there's no need tu push the
images again.

Manual installation

pip install -r requeriments.txt

Starting server

python app.py

Build Docker container

docker build -t ciricihq/wkhtmltopdf-aas .

Starting Docker container

docker run -d --name wkhtmltopdf-aas -p <hostport>:80 ciricihq/wkhtmltopdf-aas

Testing the microservice

Testing providing url to render:

curl -F "url=http://cirici.com" 'http://localhost:5000/pdf' > youramazingfile.pdf

Testing uploading contents:

curl -F "content=@test.html" 'http://localhost:5000/pdf' > youramazingfile.pdf

Testing passing html as string:

curl -F "html=<html><head> <meta charset%3D"utf8"> </head><body>Hello world</body></html>" 'http://localhost:5000/pdf' > youramazingfile.pdf

Passing options

You can use all the wkhtmltopdf options passing in a options array as following example (if option should not receive value just send the option without value):

curl -F "url=http://cirici.com" -F "options[orientation]=Landscape" -F "options[grayscale]" 'http://localhost:5000/pdf' > youramazingfile.pdf

You want to generate images? No problem, just change the pdf endpoint to jpg.

Resources

https://pypi.python.org/pypi/pdfkit

Docker Pull Command
Owner
ciricihq
Source Repository

Comments (0)