Document Template Processing Service

A lightweight microservice for processing Word document templates with data injection and PDF conversion.

Get started now View on GitHub


Features

✨ Easy Template Processing: Transform Word documents with dynamic data injection
πŸ”„ Automatic PDF Conversion: Seamless conversion to PDF using Gotenberg
πŸš€ Fast REST API: Built with FastAPI for high performance
🐳 Docker Ready: Complete containerization with Docker Compose
☸️ Kubernetes Support: Production-ready deployment manifests

Technology Stack

  • Backend: FastAPI 0.115.6, Python 3.12
  • Templating: docxtpl 0.19.0 (Jinja2-based)
  • PDF Generation: Gotenberg 8
  • Deployment: Docker, Kubernetes

Getting Started

Quick Start with Docker Compose

The fastest way to get up and running:

git clone https://github.com/etherisc-services/document-templating-service.git
cd document-templating-service
docker compose up -d

Your service will be available at:

Next Steps

  1. πŸ“– Read the Installation Guide for detailed setup options
  2. πŸ”§ Check the Usage Guide for service usage and examples
  3. πŸš€ Start building your document templates!

API Examples

Basic Template Processing

Process a Word template with dynamic data:

curl -X POST \
  http://localhost:8000/api/v1/process-template-document \
  -F "file=@template.docx" \
  -F "data={\"name\":\"John Doe\",\"amount\":150.00}" \
  --output result.pdf

Template Processing with Images

Process templates with embedded images:

# Encode image and create request
IMAGE_BASE64=$(base64 -w 0 logo.png)
REQUEST_DATA='{"template_data":{"name":"John Doe","logo":""},"images":{"company_logo":{"data":"'$IMAGE_BASE64'","width_mm":50,"height_mm":20}}}'

curl -X POST \
  http://localhost:8000/api/v1/process-template-document-with-images \
  -F "file=@template.docx" \
  -F "request_data=$REQUEST_DATA" \
  --output result.pdf

Documentation

πŸ“‹ Installation Guide
Complete setup instructions for all environments

πŸ”§ Usage Guide
Service usage with templating examples

πŸ–ΌοΈ Image Support Guide
Include inline images in document templates

🐳 Docker Integration Guide
Integrate with existing Docker Compose stacks


About

This service combines the power of docxtpl for Word document templating with Gotenberg for PDF conversion, providing a simple REST API for document processing workflows.

Original Author

Etherisc GmbH (Originally created by M.B.C.M (PapiHack))


Contributing

We welcome contributions! Please feel free to submit a Pull Request. Make sure to include a description with your PR.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Copyright © 2024 Etherisc GmbH. Distributed under the MIT license.