Skip to content

addImage problem #2145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
muratyilmaz-dev opened this issue Sep 24, 2021 · 0 comments
Open

addImage problem #2145

muratyilmaz-dev opened this issue Sep 24, 2021 · 0 comments

Comments

@muratyilmaz-dev
Copy link

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

@Progi1984 Progi1984 added this to the 1.3.0 milestone Aug 22, 2024
@Progi1984 Progi1984 modified the milestones: 1.3.0, 1.3.1 Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants