在PHP中替换Visio Diagram的图片形状
Contents
[
Hide
]
Aspose.Diagram - 替换 Visio 的图片形状 Diagram
要使用 Visio Diagram 替换图片形状Aspose.Diagram Java 用于 PHP 只需调用替换图片形状模块。在这里您可以看到示例代码。
PHP代码
# Create instance of Diagram
$diagram = new Diagram($dataDir."Drawing.vsd");
\# convert image into bytes array
$fi = new File($dataDir."star.png");
$files=new Files();
$file_content = $files->readAllBytes($fi->toPath());
$shapes = $diagram->getPages()->getPage("Flow 1")->getShapes();
$i = 0;
$typeValue=new TypeValue();
while ($i<(int)(string)$shapes->getCount()) {
$shape = $shapes->get($i);
\# Filter shapes by type Foreign
if ($shape->getType() == $typeValue->FOREIGN){
\# replace picture shape
$shape->getForeignData()->setValue($file_content);
}
$i+=1;
}
\# Save diagram
$saveFileFormat=new SaveFileFormat();
$diagram->save($dataDir."ReplacePictureShape.vdx", $saveFileFormat->VDX);
print "Replaced picture shape successfully!".PHP_EOL;
下载运行代码
下载替换Visio Diagram (Aspose.Diagram)的图片形状来自以下任何社交编码网站: