I have 3 Blade files that are written in HTML, I am currently using WKHTMLTOPDF to export them to a PDF format, I now want to export the same HTML files to a Word Document.
So far, the best package for Laravel I can find is PhpWord.
Snippet of code:
<div class="page-break"></div>
<h3>Introduction</h3>
<p></p>
<p></p>
My code so far:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$report = view('reports.audit-report', $data)->render();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $report, true);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');
It is currently returning this error:
DOMDocument::loadXML(): Opening and ending tag mismatch: link line 1 and div in Entity, line: 1
The annoying thing is, is that no matter what line(s) I remove, that error always persists, until I remove literally every line of HTML!
I can prevent this error from happening by using the following code:
libxml_use_internal_errors(true);
However then, it returns:
ErrorException in Html.php line 136: Trying to get property of non-object
Has anybody successfully resolved these errors before? If you require any more code, please just let me know. Many thanks.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1re30dO
via IFTTT
Aucun commentaire:
Enregistrer un commentaire