Sign inSign up

papihack/document-template-processor

By papihack

•Updated over 3 years ago

A lightweight microservice that allow you to process your docs with a template engine system

Image
0

383

papihack/document-template-processor repository overview

⁠🚀 Document Template Processor Service 🚀

python FastAPI docker Issues PR MIT licensed

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 project's source code⁠ on my github repo.

⁠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 cant start the service by creating a container with :

     docker run -d -p 8000:8000 -e GOTENBERG_API_URL=your-host-ip:3000 --name document-template-processor papihack/document-template-processor
    
  • Visit the API Documentation at http://localhost:8000/docs⁠ or http://localhost:8000/redoc⁠

⁠Up & Running with Docker Compose

I also setup a docker-compose stack available here⁠. So 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

⁠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 :

  • The file parameter that contains your Word Document Template

  • The data parameter that is a JSON object with data or variable that we are going to inject in the file parameter

As a response, you'll get back its corresponding PDF file as a result.

⁠Example
Template ExamplePostman 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

screenshot

⁠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

Tag summary

Content type

Image

Digest

sha256:ebd0d3d44…

Size

76 MB

Last updated

over 3 years ago

docker pull papihack/document-template-processor