Skip to content

I'm inserted an image using the addimage function without any error, but the image is not displayed #2682

@gbnew

Description

@gbnew

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

  • 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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions