Skip to content
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

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

Open
1 of 2 tasks
gbnew opened this issue Sep 18, 2024 · 2 comments

Comments

@gbnew
Copy link

gbnew commented Sep 18, 2024

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)
@gbnew
Copy link
Author

gbnew commented Sep 19, 2024

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.

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
@gbnew and others