Skip to main content

Python docx template engine

Project description


====================
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 <http://docxtpl.readthedocs.org>`_


News
====
0.5.0 (2018-08-03)
-------------------
- An hyperlink can now be used in RichText

0.4.13 (2018-06-21)
-------------------
- Subdocument can now be based on an existing docx

0.4.12 (2018-06-07)
-------------------
- Add font option in RichText

0.4.11 (2018-05-16)
-------------------
- Better tabs and spaces management for MS Word 2016

0.4.10 (2018-05-08)
------------------
- Wheel distribution

0.4.9 (2018-05-08)
------------------
- Manage autoscaping on InlineImage, Richtext and Subdoc

0.4.8 (2018-04-20)
------------------
- Purge MANIFEST.in file

0.4.7 (2018-02-03)
------------------
- Accept variables starting with 'r' in {{}} when no space after {{

0.4.6 (2017-10-15)
------------------
- Remove debug traces

0.4.5 (2017-10-15)
------------------
- Add {% vm %} to merge cell vertically within a loop (Thanks to Arthaslixin)

0.4.4 (2017-10-13)
------------------
- use six.iteritems() instead of iteritems for python 3 compatibility

0.4.3 (2017-10-13)
------------------
- Fixed Bug #95 on replace_pic() method

0.4.2 (2017-10-05)
------------------
- Add replace_pic() method to replace pictures from its filename (Thanks to Riccardo Gusmeroli)

0.4.1 (2017-09-10)
------------------
- Improve image attachment for InlineImage ojects

0.4.0 (2017-09-09)
------------------
- Add replace_media() method (useful for header/footer images)
- Add replace_embedded() method (useful for embedding docx)

0.3.9 (2017-06-27)
------------------
- Fix exception in fix_table()

0.3.8 (2017-06-20)
------------------
- Fix bug when using more than one {{r }} or {%r %} in the same run

0.3.7 (2017-06-13)
------------------
- Fix git tag v0.3.6 was in fact for 0.3.5 package version
so create a tag 0.3.7 for 0.3.7 package version

0.3.6 (2017-06-10)
------------------
- Better head/footer jinja2 handling (Thanks to hugokernel)

0.3.5 (2017-02-20)
------------------
- Fix bug where one is using '%' (modulo operator) inside a tag

0.3.4 (2017-02-14)
------------------
- Add Listing class to manage \n and \a (new paragraph) and escape text AND keep current styling

0.3.3 (2017-02-07)
------------------
- Add {%tc } tags for dynamic table columns (Thanks to majkls23)

0.3.2 (2017-01-16)
------------------
- Remove version limitation over sphinx package in setup.py

0.3.1 (2017-01-16)
------------------
- Add PNG & JPEG in tests/test_files/

0.3.0 (2017-01-15)
------------------
- You can now add images directly without using subdoc, it is much more faster.

0.2.5 (2017-01-14)
------------------
- Add dynamic colspan tag for tables

0.2.4 (2016-11-30)
------------------
- Fix /n in RichText class

0.2.3 (2016-08-09)
------------------
- Add Python 3 support for footer and header

0.2.2 (2016-06-11)
------------------
- Fix bug when using utf-8 chracters inside footer or header in .docx template
It now detects header/footer encoding automatically

0.2.1 (2016-06-11)
------------------
- Fix bug where using subdocs is corrupting header and footer in generated docx
Thanks to Denny Weinberg for his help.

0.2.0 (2016-03-17)
------------------
- Add Header and Footer support (Thanks to Denny Weinberg)

0.1.11 (2016-03-1)
------------------
- '>' and '<' can now be used inside jinja tags

0.1.10 (2016-02-11)
-------------------
- render() accepts optionnal jinja_env argument :
useful to set custom filters and other things

0.1.9 (2016-01-18)
------------------
- better subdoc management : accept tables

0.1.8 (2015-11-05)
------------------
- better xml code cleaning around Jinja2 tags

0.1.7 (2015-09-09)
------------------
- python 3 support

0.1.6 (2015-05-11)
------------------
- remove debug code
- add lxml dependency

0.1.5 (2015-05-11)
------------------
- fix template filter with quote

0.1.4 (2015-03-27)
------------------
- add RichText support

0.1.3 (2015-03-13)
------------------
- add subdoc support
- add some exemples in tests/

0.1.2 (2015-03-12)
------------------
- First running version

Project details


Release history Release notifications | RSS feed

This version

0.5.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docxtpl-0.5.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docxtpl-0.5.0-py2-none-any.whl (9.3 kB view details)

Uploaded Python 2

File details

Details for the file docxtpl-0.5.0.tar.gz.

File metadata

  • Download URL: docxtpl-0.5.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for docxtpl-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1b424b5e59d75e6f8ff8e1f36952b5a53d8666701b8c1ede7b0d13b7bd05a7cb
MD5 71583615ab1b92eb984a9987fd86fba0
BLAKE2b-256 7649cd208d67cb537643c1caa22e951ff8bd04388bd4956039f0e349c45c5d35

See more details on using hashes here.

File details

Details for the file docxtpl-0.5.0-py2-none-any.whl.

File metadata

  • Download URL: docxtpl-0.5.0-py2-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for docxtpl-0.5.0-py2-none-any.whl
Algorithm Hash digest
SHA256 5a76de61c03916b16ece5088074506583beec9357f1d5549dae9e9e4d1d82642
MD5 c84de046e81dfeaf529f0622497cbdc8
BLAKE2b-256 6dd30bd5c346b8599e6a125593be020e193233e946dab46764a5a66df47d7661

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page