This fork of docxtemplater CLI includes the support for open-docxtemplater-image-module.
The package below includes a copy of docxtemplater and open-docxtemplater-image-module.
npm install -g docxtemplater-cli-open-image-module
Browse to folder 'examples' and run the following in your console
docxtemplater input.pptx data.json output.pptx
This is a simple JSON file. Assuming we are working on the template 'input.pptx' provided with this package in 'examples' folder, we write below JSON to replace tags in the template by their respective value.
{
"first_name": "John",
"last_name": "Doe",
"description": "He is awesome",
"phone": "+4412345678",
"picture": "johndoe.png"
}
As you can see we have included a picture of John Doe (johndoe.png). For this picture to be correctly rendered in the output, we must explicitly activate the Open Source Image Module open-docxtemplater-image-module. Note that all images must be under the directory 'imageDir'.
{
"first_name": "John",
"last_name": "Doe",
"description": "He is awesome",
"phone": "+4412345678",
"picture": "johndoe.png",
"config": {
"modules": ["open-docxtemplater-image-module"],
"imageDir": "."
}
}
More on how to write your templates in docxtemplater documentation.