Hello,
I'm using phpdocx to generate a DOCX document from HTML that is later edited in Microsoft Publisher. Unfortunately, Publisher does not display the content of certain table cells correctly — especially when those cells contain multiple blocks or line breaks. The content sometimes disappears entirely.
To work around this, I’ve removed all <p>
tags from my HTML and replaced them with <br />
and inline styles only. This helps in many cases, but not all.
I noticed that enabling strictWordStyles = true
makes the document render correctly in Publisher (no missing content), but then I lose formatting options like background colors in table headers.
My questions:
Is this a known issue with Publisher compatibility?
Is there a way to apply
strictWordStyles = true
only to specific parts of the document, for example, only inside certain table cells?
For context, here's a simplified example of what gets generated:
Problematic output (Publisher breaks rendering):
<w:p>
<w:pPr>
<w:widowControl w:val="on"/>
<w:pBdr/>
<w:spacing w:before="105" w:after="30" w:line="379" w:lineRule="auto"/>
</w:pPr>
<w:r>
<w:rPr>...</w:rPr>
<w:t>Hl. Messe</w:t>
</w:r>
<w:r>
<w:rPr>...</w:rPr>
<w:br/>
<w:t>nach Meinung</w:t>
</w:r>
</w:p>
Working output in Publisher:
<w:p>
<w:pPr>
<w:widowControl w:val="on"/>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>Hl. Messe</w:t>
</w:r>
<w:r>
<w:rPr/>
<w:br/>
<w:t>nach Meinung</w:t>
</w:r>
</w:p>
Kind regards,
Anna Krämer