Skip to content

elapouya/python-docx-template

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

d9801fd

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
March 12, 2023 11:04
March 12, 2023 11:04
November 18, 2018 17:56
March 13, 2015 11:59
March 13, 2015 11:59
March 12, 2023 11:04
March 12, 2015 18:13
April 20, 2018 18:35
June 12, 2022 16:28
July 14, 2022 18:16
April 29, 2020 14:41
July 31, 2021 12:49

python-docx-template

Use a docx as a jinja2 template

Introduction

This package uses 2 major packages :

  • python-docx for reading, writing and creating sub documents
  • jinja2 for managing tags inserted into the template docx

python-docx-template has been created because python-docx is powerful for creating documents but not for modifying them.

The idea is to begin to create an example of the document you want to generate with microsoft word, it can be as complex as you want : pictures, index tables, footer, header, variables, anything you can do with word. Then, as you are still editing the document with microsoft word, you insert jinja2-like tags directly in the document. You save the document as a .docx file (xml format) : it will be your .docx template file.

Now you can use python-docx-template to generate as many word documents you want from this .docx template and context variables you will associate.

Share

If you like this project, please rate and share it here : http://rate.re/github/elapouya/python-docx-template

Documentation

Please, read the doc

Other projects

Have a look at some of my other projects :