我正在研究phpword,当将word转换为html时,图表很好地转换为图像,因此我想从图像或图表中了解图像的来源,并在phpword文件中查找此代码: https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/Element/Image.php
,我找到了这个文件: https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/Writer/HTML/Element/Image.php 所以我需要在id属性中添加源代码:
if (!$parentWriter->isPdf()) {
$imageData = $this->element->getImageStringData(true);
if ($imageData !== null) {
$styleWriter = new ImageStyleWriter($this->element->getStyle());
$style = $styleWriter->write();
$imageData = 'data:' . $this->element->getImageType() . ';base64,' . $imageData;
$content .= $this->writeOpening();
$content .= "<img id="imagesource" border=\"0\" style=\"{$style}\" src=\"{$imageData}\"/>";
$content .= $this->writeClosing();
}
}