I am trying to make a website witch people submits a form. One part of this form is using ckeditor to get input from user. Becasuse of data that is coming from ckeditor is html you need to turn html to openxml to use tamplatingprocessor of phpword but whenever i run my script i am geting blank section on the output file.
PHP Code:
$toOpenXML = HTMLtoOpenXML::getInstance()->fromHTML($data[1]);
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('template.docx');
$templateProcessor->setValue('section1', $data[0]);
$templateProcessor->setValue('section2', $toOpenXML);
$templateProcessor->setValue('section3', $specialdata);
$templateProcessor->setValue('section4', $data[2]);
$templateProcessor->setValue('section5', $data[3]);
$file_name1 = $file_name.'.docx';
$file_name2 = $file_name.rand().'.docx';
if(file_exists($file_name1)== false){
$templateProcessor->saveAs($file_name1);
}elseif(file_exists($file_name2)== false){
$templateProcessor->saveAs($file_name2);
}else{
$info['er'] = "3";
}
Output of HTMLtoOpenXML:
<w:p>
<w:pPr>
<w:pStyle w:val='OurStyle2'/>
</w:pPr>
<w:r>
<w:t xml:space='preserve'>foo</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val='OurStyle2'/>
</w:pPr>
<w:r>
<w:t xml:space='preserve'>bar</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val='OurStyle2'/>
</w:pPr>
<w:r>
<w:t xml:space='preserve'></w:t>
</w:r>
</w:p>
i dont thing problem is about HTMLtoOpenXML i thing problem is about
All sections working except section2 on output file. The place where data of section2 supposed to be is just empty.