The following code describes the way to use a HTML content string as header and / or footer in a DOCX. In this case no DOCX with template variables as template is used.
<?php
require_once '/vendor/phpdocx/classes/CreateDocx.inc';
$docx = new CreateDocx();
$docx->setEncodeUTF8();
/* HEADER */
$header_wordml = $docx->embedHTML('<table><tr><td>test</td><td align="right">test</td></tr></table>', array(
'rawWordML' => true,
));
$header_wordml_fragment = $docx->createWordMLFragment(array($header_wordml));
$docx->addHeader(array('default' => $header_wordml_fragment));
/* CONTENT */
$docx->embedHTML('<h1>Content</h1><p>Lorem ipsum dolor sit amet</p>', array(
'downloadImages' => true,
'parseDivsAsPs' => false,
'parseFloats' => true,
));
/* Footer */
$footer_wordml = $docx->embedHTML('<p align="center">Some text</p>', array(
'rawWordML' => true,
));
$footer_wordml_fragment = $docx->createWordMLFragment(array($footer_wordml));
$docx->addFooter(array('default' => $footer_wordml_fragment));
$docx->createDocx();
?>
If somebody find an easier way, please link it here.
Greets