Cymro
Cymro

Reputation: 1297

PHPWord bracket causes rendered Word document to be un-openable

Using PHPWord, I've managed with this line:

$section->addText('<');

to provoke an Error in Microsoft Word opening the .docx file:

+---------------------------------------------------------------+
| Microsoft Office Word                                     ? X |
+---------------------------------------------------------------+
| The file BrynergyTest.docx cannot be opened because there are |
| problems with the contents.                                   |
|                                        [ OK ] [ Details >>> ] |
+---------------------------------------------------------------+

Microsoft Office Word showing a message box dialog with the message "The file BrynergyTest.docx cannot be opened because there are problems with the contents." with an "OK" and a button to show more details.

Other symbols, such as:

$section->addText('t');

work fine.

I expected the result to have the Word XML file with the contents of the less-than-sign "<" (U+003C LESS-THAN SIGN).

Upvotes: 0

Views: 29

Answers (1)

Cymro
Cymro

Reputation: 1297

I found this answer:

\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);

Upvotes: 2

Related Questions