PHPWord
PHPWord copied to clipboard
I'm inserted an image using the addimage function without any error, but the image is not displayed
Describe the bug and add attachments
i check the document ,images file is not in the word zip file.
Expected behavior
why the image is not in file,the path is correct.
Steps to reproduce
foreach ($sceneCheckList as $item) {
$table->addRow();
$table->addCell(200)->addText($row_total++);
//$table->addCell(2000)->addText($item['picUrl']);
// 第二列:插入图片
$picUrlAry=explode(',',$item['picUrl']);
//var_dump($picUrlAry);
if (count($picUrlAry)>0) {
$cell = $table->addCell(2000); // 创建一个较大的单元格
$cell->addText('隐患图片:'); // 添加文本标题
$cell->addBreak(); // 换行
foreach ($picUrlAry as $picUrl) {
if($picUrl){
$imageStyle = array('width' => 100, 'height' => 100, 'wrappingStyle' => 'behind');
//echo "<img src='../../".$picUrl."'>";
$filePath = realpath($picUrl);
if ($filePath !== false) {
echo "文件的绝对路径是: $filePath";
} else {
echo "文件不存在或者路径有误";
}
$cell->addImage($picUrl, $imageStyle);
$cell->addBreak(); // 换行
}
}
} else {
$table->addCell(2000)->addText('无图片');
}
PHPWord version(s) where the bug happened
3
PHP version(s) where the bug happened
7.4.3
Priority
- [X] I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
- [ ] I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
i try it again ,if i use section container the images can insert into document,but i use cell container the image only a blank without picture,the php had aready turn on the GD library.
Facing the same issue