Forum


Replies: 1   Views: 1285
Phpdocx 5.5: css style's style code inserted as text in the docx file all of a sudden
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 davelavinsky  · 17-06-2021 - 16:00

I didn't have this issue before. It was brought to my attention only recently, so I don't know for how long this issue remained online. No code was changed / modified in the last year or so.

Using phpdocx-corporate-5.5, PHP 7.4.18

$style = "<style type='text/css'>
h1 { page-break-before:always; }
h1:first-child { page-break-before:avoid; }
p.sample { font-weight:bold; background-color:#FFFF00; }
p.empty { color:#fff; background-color:blue; }

.tbl-summary { border-collapse:collapse; font-size:12px; }
.tbl-summary thead tr th { font-weight:bold; }
.tbl-summary thead tr th,
.tbl-summary thead tr td,
.tbl-summary tbody tr td
{
    border:1px solid #000000;
    padding:2px;
    text-align:center;
    width:100px;
}
.tbl-summary tbody tr td:first-child
{
    text-align:left;        
}
</style>";

$html = $style;

$html .= "<p class='sample'>Test</p>";

.
.
.
$docx->embedHTML($html);

All the html code gets displayed properly. But this style code is showing as text in the docx. It's not getting inserted as a CSS style.

h1 { page-break-before:always; } h1:first-child { page-break-before:avoid; } p.sample { font-weight:bold; background-color:#FFFF00; } p.empty { color:#fff; background-color:blue; } .tbl-summary { border-collapse:collapse; font-size:12px; } .tbl-summary thead tr th { font-weight:bold; } .tbl-summary thead tr th, .tbl-summary thead tr td, .tbl-summary tbody tr td { border:1px solid #000000; padding:2px; text-align:center; width:100px; } .tbl-summary tbody tr td:first-child { text-align:left; }