I get html body from tinymce that contains images and text (paragraph). But I get blank images when I'm trying to insert it to template.
There is my code:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('./template.docx');
$section = $phpWord->addSection();
$content = '<p>Test</p> <img src="https://www.sciencemag.org/sites/default/files/styles/inline__450w__no_aspect/public/sparrow_16x9_0.jpg" />';
Html::addHtml($section, $content);
$xml = getXMLContent($section);
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(false);
$templateProcessor->setValue('test', $xml);
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
$templateProcessor->saveAs('./result.docx');
function getXMLContent($section) {
$xmlWriter = new XMLWriter(XMLWRITER::STORAGE_MEMORY, './', Settings::hasCompatibility());
$containerWriter = new Container($xmlWriter, $section);
$containerWriter->write();
return $xmlWriter->getData();
}
Am I doing something wrong? Or there is an another way to do it?