嗨,伙计们,
我这里有一段代码:
System.Net.WebClient wc = new System.Net.WebClient();
byte[] data = wc.DownloadData(xmlTempNode.Attributes["imageurl"].Value.ToString());
MemoryStream ms = new MemoryStream(data);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
string strImagePath = pptdirectoryPath + "\\" + currentSlide + "_" + shape.Id + ".png";
img.Save(strImagePath);
tempSlide.Shapes.AddPicture(strImagePath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, Convert.ToInt32(xmlTempNode.Attributes["imgwidth"].Value), Convert.ToInt32(xmlTempNode.Attributes["imgheight"].Value));
shape.Delete();
tempSlide.Shapes.AddPicture
适用于较小的图像,当分辨率较高时它会失败(这里失败意味着无限时间没有收到响应,并在刷新页面时抛出异常)。
异常消息:远程过程调用失败。(来自 HRESULT 的异常:0x800706BE)在 Microsoft.Office.Interop.PowerPoint.Shapes.AddPicture(字符串文件名,MsoTriState LinkToFile,MsoTriState SaveWithDocument,单左,单上,单宽,单高)。
任何帮助,将不胜感激。