Forum


Replies: 8   Views: 3850
Importstyles issues
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Alain DIAS  · 18-11-2015 - 16:55

I tried to import my own template style thanks to importStyles with merge parameter and array of my customs styles.

I apply those styles to my document. But when I opened it (the generated document), styles witch I imported are not applied correctly or not applied any more.The last styles called section, subSection are never applied and title, subTitle, subSubTitle are applied but with wrong color.

Please Help me (please see below my code). I'm in v5.0

 

$path = $this->container->getParameter('kernel.root_dir') . '/../web/bundles/rffconcertationsrest/templates/report.docx';

$docx = new \Phpdocx();

$docx->importStyles($path, 'merge', array(
            'title',
            'subTitle',
            'subSubTitle',
            'section',
            'subSection'
        ));

//variables are of course initialized
$docx->addText($title, array('pStyle' => 'title'));
        $docx->addText($subTitle, array('pStyle' => 'subTitle'));
        $docx->addText($subSubTitle, array('pStyle' => 'subSubTitle'));
        $docx->addBreak(array('type' => 'page'));
        $docx->addText($section1, array('pStyle' => 'section'));
        $docx->addText($subSection11, array('pStyle' => 'subSection'));

$path = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/';
        $fullPath = $path . 'test';
        $docx->createDocx($fullPath);