Description
I tried to add images in two different ways. But I am getting the following error.
Can you please help?
Thanks.
addHTML()
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $nms_export_html, false, false);
addImage()
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Shared\Converter;
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code
$section = $phpWord->addSection();
$section->addImage('customer_logo.jpg');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
Fatal error: Uncaught PhpOffice\PhpWord\Exception\Exception: Invalid parameters passed. in /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007/Part/Rels.php:127 Stack trace: #0 /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007/Part/Rels.php(95): PhpOffice\PhpWord\Writer\Word2007\Part\Rels->writeRel(Object(PhpOffice\PhpWord\Shared\XMLWriter), 7, 'officeDocument/...', '', '') #1 /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007/Part/Rels.php(70): PhpOffice\PhpWord\Writer\Word2007\Part\Rels->writeMediaRel(Object(PhpOffice\PhpWord\Shared\XMLWriter), 7, Array) #2 /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007/Part/RelsDocument.php(46): PhpOffice\PhpWord\Writer\Word2007\Part\Rels->writeRels(Object(PhpOffice\PhpWord\Shared\XMLWriter), Array, Array) #3 /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007.php(138): PhpOffice\PhpWord\Writer\Word2007\Part\RelsDocument->write() #4 /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/PhpWord.p in /srv/www/htdocs/vendor/phpoffice/phpword/src/PhpWord/Writer/Word2007/Part/Rels.php on line 127