There is a bug in the "PRO library" when I want to generate documents one after the other using a template and the method "addTemplateVariable" with the "html" option.
The first file can be open but the others are corrupted and Word send an error message.
However, I corrected the problem in my own version of the library, here it is :
The class "CreateDocx" is, as it should, created again for each new document, but because of his own nature, the singleton "CreateTemplate" is only created once.
The array "$embedFiles" continues to be filed with the new HTML documents, and the DOCX documents generated possess all the old files of the previous documents.
On the other hand, only the relations between the new variables of "html" type and the newly html files created in the folder "word/" of the DOCX are set.
This is where the problem comes.
To resolve it, I don’t use the class "CreateTemplate" as a singleton, but instead I create a new instance for each new DOCX document.
I create a variable "private $_template" in the class "CreateDocx" and in the method "addTemplateVariable" I changed the code :
$this->_template = new CreateTemplate;
'Assign and replace text variable ' . $var . ' in template.'
$this->_template->replaceVariable($var, $value, $settings);
Now, every documents are generated and can be opened.
I hope this will help you to improve the library.