Step: enrich-docx¶
Enrichment step for MS Word (docx) documents.
Input¶
Gets a docx document as input.
Output¶
Results in a docx document as input.
Options¶
Options are used as a dictionary for rewrites with the following syntax:
Keys can be prefixed with:
rewrite:and followed by path of file to be rewritten(currently there are no other prefixes then ``rewrite``)
Values can be prefixed with:
static:and followed by path to a file in a template; then it is used as-is to rewrite the original file indocxrender:and followed by path to a file in a template; then it is rendered first asjinjatemplate with document context provided and result is used to rewrite the original file indocx
Notes¶
Internally, the step unpacks the provided
docxfile, makes adjustments on the level of internalXML(and other) files, and packs it back todocx.To figure out what to rewrite, you should first generate the
docxlater used as input, unzip it and go through the contents.A good way to adjust things is to put there some placeholder first (e.g. via
reference.docxpassed topandoc) and then just adjust the placeholder with other / dynamic content.Paths to files in a template are relative to template root, i.e. directory with
template.json.It does not matter if the file to be rewritten is missing in the
docx, then the desired file is simply added.The document context is provided in
ctxvariable, other variables, filters, and tests are documented in other documents (same as forjinjastep).
Example¶
{
"name": "enrich-docx",
"options": {
"rewrite:word/footer1.xml": "static:src/docx/footer1.xml",
"rewrite:word/header1.xml": "render:src/docx/header1.xml.j2"
}
}