🚀 Document Template Processing Service 🚀

This is a simple and lightweight microservice that allow you to process your Word documents with a templating system, in order to hydrate it by injecting data or variables defined in it and get back its associated PDF result.
Feel free to checkout the official docker image on my docker hub.
Notes
For transforming the docx result to PDF you’ll need have an instance of Gotenberg up and running and provide its ROOT URL as an environment variable to the microservice.
Installation
-
First and foremost you’ll need to have an instance of Gotenberg. You can easily have one by running the following docker command :
docker run --name gotenberg -d -p 3000:3000 gotenberg/gotenberg:7
-
After this step done, you have the two (2) options in order to run this service :
Up & Running with Docker Compose
If you are lazy like me 😄, you can setup the project by just running the following command :
docker-compose up -d
And stop all the service with :
docker-compose stop
Or stop and remove all the service with :
docker-compose down
Up & Running with Kubernetes
If you want to deploy this project on your kubernetes cluster, you can inspect and/or edit the manifest files available in the
k8s directory before apply them.
Start by creating the namespace named utils by running :
kubectl apply -f k8s/namespace.yaml
Then, you can deploy the necessary components by running :
kubectl apply -f k8s/gotenberg -f k8s/document-template-processing
After that, feel free to create an ingress for svc/document-template-processing if you are using such kind of k8s component.
Otherwise, you can port forward the api service by running the following command before visiting http://localhost:8000/docs :
kubectl port-forward svc/document-template-processing 8000:8000 -n utils
Usage
For now, you have an endpoint named /api/v1/process-template-document that will allow you to make a POST HTTP REQUEST by sending two (2) required parameters :
As a response, you’ll get back its corresponding PDF file as a result.
Example
| Template Example |
Postman Test Result |
 |
 |
🚨 Cautions for Cloud Run 🚨
If you plan to run this on cloud, please change the gotenberg docker image with gotenberg/gotenberg:7-cloudrun or thecodingmachine/gotenberg:7-cloudrun in docker-compose.yaml file. This will allow you to save cost and so on.
For more infos, please look at Gotenberg Docs.
Screenshots

Contributing
Feel free to make a PR or report an issue 😃
Oh, one more thing, please do not forget to put a description when you make your PR 🙂
Author
评论