I'm working on an assignment where I need to capture the content generated on html and send it to word document so that it could be sent further.
I have captured the content and sent it to php using json object and generated the word document as well, however when html has special characters, it causes the word document to be corrupted. I tried using htmlspecialchars
in addText
function, but it didn't help.
Here is my php code
\PhpOffice\PhpWord\Autoloader::register();
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$jsonData2 =json_decode($_POST['outputData'],true);
foreach ($jsonData2 as $key => $value) {
$section-> addTextBreak();
$section->addText($key, array('size' => 16, 'bold' => true, 'color' => '#3b5999'));
$section-> addTextBreak(2);
foreach ($value as $key => $value) {
$section->addText($value, array('size' => 11));
$section-> addTextBreak();
}
}
can someone how to capture the special characters and display it to the word doc so that it doesn't cause file to be corrupted