I am trying to covert HTML formatted with Php word.
I created an html form with summernote. Summernote allows the user to format text. This text is saved to the database with html tags.
Next using phpWord, I would like to output the captured information into a word document. Please see the code below:
$rational = DB::table('rationals')->where('qualificationheader_id',$qualId)->value('rational');
$wordTest = new \PhpOffice\PhpWord\PhpWord();
$newSection = $wordTest->addSection();
$newSection->getStyle()->setPageNumberingStart(1);
\PhpOffice\PhpWord\Shared\Html::addHtml($newSection,$rational);
$footer = $newSection->addFooter();
$footer->addText($curriculum->curriculum_code.'-'.$curriculum->curriculum_title);
$objectWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordTest,'Word2007');
try {
$objectWriter->save(storage_path($curriculum->curriculum_code.'-'.$curriculum->curriculum_title.'.docx'));
} catch (Exception $e) {
}
return response()->download(storage_path($curriculum->curriculum_code.'-'.$curriculum->curriculum_title.'.docx'));
I get the error below:
ErrorException (E_WARNING) DOMDocument::loadXML(): Namespace prefix o on p is not defined in Entity, line: 1
from Covert HTML with PhpWord: error - DOMDocument::loadXML(): Namespace prefix o on p is not defined in Entity
No comments:
Post a Comment