I've of course already read the API documentation in detail. Import a template seems to be a tricky part.
I tried the code below. None of my custom styles are applied. I tried to open the template file to see what is generated. But Word said to me that problems have been detected (and doesn't want to open). I suppose that is why my custom styles aren't applied (maybe).
private function generateTemplate()
{
// Create a new document
$docx = new \Phpdocx();
// Imports style from the template
$path = $this->container->getParameter('kernel.root_dir') . '/../web/bundles/rffconcertationsrest/templates/report.docx';
$docx->parseStyles($path);
$uploadPath = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/';
$this->templatePath = $uploadPath.'templateParseStyles.docx';
$docx->createDocx($uploadPath.'templateParseStyles');
}
public function generate(){
$this->generateTemplate();
// Create a new document
$docx = new \Phpdocx();
$docx->importStyles($this->templatePath, 'merge', array(
'title',
'subTitle',
'subSubTitle',
'section',
'subSection')
);
$docx->addText($title, array('pStyle' => 'title'));
}