Forum


Replies: 2   Views: 3490
Styling text when using addhtml()
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 patrick.white  · 29-02-2012 - 15:35

I'm trying to incorporate global styling across the entire docx file. I'm using <style> tags that style the content. However, I noticed something strange:

[b]This code works fine:[/b]
[code]
$docx = new CreateDocx();
$html= '<style>p {font-family:arial;font-size:33px;}</style>';
$html.= '<p>Some sample text. <strong><span>Some bold text.</span></strong></p>';
$docx->addHTML($html);
$docx->createDocxAndDownload('example_html');
[/code]




[b]This code fails![/b]
[code]
$docx = new CreateDocx();
$html= '<style>p {font-family:arial;font-size:33px;}</style>';
$docx->addHTML($html);
$html= '<p>Some sample text. <strong><span>Some bold text.</span></strong></p>';
$docx->addHTML($html);
$docx->createDocxAndDownload('example_html');
[/code]

In the second example, the style gets ignored. Why would adding the style coding separately fail?

Thanks,
-Patrick