docxtemplater
docxtemplater is a library to generate docx/pptx documents from a docx/pptx template. It can replace {placeholders} with data and also supports loops and conditions. The templates can be edited by non-programmers, eg for example your clients.
Features
- Replace a {placeholder} by a value
- Use loops: {#users} {name} {/users}
- Use loops in tables to generate columns
- Use expressions {product.unit_price*product.count} with angular Parsing
- Insert custom XML {@rawXml} (for formatted text for example)
Quickstart
- Installation in node
- Installation in the browser
- Generate a document in node
- Generate a document in browser
Documentation
The full documentation of the latest version can be found on read the docs.
See CHANGELOG.md for information about how to migrate from older versions.
Similar libraries
They are a few similar libraries that work with docx, here’s a list of those I know a bit about:
- docx4j :JAVA, this is probably the biggest docx library out there. They is no built in templating engine, but you can generate your docx yourself programmatically
- docx.js: Javascript in the browser, you can create (not modify) your docx from scratch, but only do very simple things such as adding non formatted text
- xlsx-templater : its working quite well, does the same as here but for xlsx
Modules
Functionality can be added with modules. There is yet no documentation on how to write modules yourself because the API might change in the future, but you can open an issue if you have any question about it.
Here is the list of existing modules:
Free modules (by docxtemplater core team members):
- Image module using the syntax:
{%image}
, https://github.com/open-xml-templating/docxtemplater-image-module (v3 module)
Pro modules (developped by docxtemplater core team members):
- Html Module to insert formatted text in a docx document https://modules.docxtemplater.com/modules/html/
- Slides Module to create multiple slides dynamically https://modules.docxtemplater.com/modules/slides/
- Subtemplater Module to include a document inside an other document https://modules.docxtemplater.com/modules/subtemplate
- Table module to create beautiful tables https://modules.docxtemplater.com/modules/table
User contributed modules :
- Chart Module using the syntax:
{$chart}
, user contributed https://github.com/prog666/docxtemplater-chart-module (v2 module) - Hyperlink module using the syntax:
{^link}
, https://github.com/sujith3g/docxtemplater-link-module (v2 module)
Professional Support
I can give your company support for installing, extending, answering support questions, or maintainning your app that runs docxtemplater. You can find my email address on my profile