我想使用setSelectedDataAsync和Office.CoercionType.Image将图像插入到PowerPoint幻灯片中,如下所示:
Office.context.document.setSelectedDataAsync(image, {
coercionType: Office.CoercionType.Image,
imageLeft: 5,
imageTop: 5,
imageWidth: 100,
imageHeight: 100
});该系统适用于资源,我只需将图像插入到画布中,然后将其转换为数据URL:
const image = new Image();
image.src = props.url;
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);然后我们只需将画布插入幻灯片:
var cvs = canvas.current;
var result = cvs.toDataURL().split(",")[1];
Office.context.document.setSelectedDataAsync(result, {
coercionType: Office.CoercionType.Image,
imageLeft: 5,
imageTop: 5,
imageWidth: canvas.current.width / 3,
imageHeight: canvas.current.height / 3
});问题是这个系统不能处理外部图像。我得到了错误"SecurityError“,因为一旦在画布中插入了外部图像,干净的原点标志就被设置为false。如何插入外部图像?
谢谢。
发布于 2021-03-19 11:25:33
这是一个用于在您的Office外接程序中插入图像的tutorials。
https://stackoverflow.com/questions/66599831
复制相似问题