Hie guys,
I have a block of code here:
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
works fine for smaller images,and it fails when resolution is higher(here fail means response is not received for infinite time and throws exception when page is refreshed).
Exception Message: The remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Microsoft.Office.Interop.PowerPoint.Shapes.AddPicture(String FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, Single Left, Single Top, Single Width, Single Height).
Any help would be appreciated.
Finally i solved the issue.used below code to addpicture
tempSlide.Shapes.AddPicture(strImagePath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Convert.ToInt32(shape.Left), Convert.ToInt32(shape.Top), Convert.ToInt32(xmlTempNode.Attributes["imgwidth"].Value), Convert.ToInt32(xmlTempNode.Attributes["imgheight"].Value));//load new image to shape
The problem was, i was sending msoFalse for LinkToFile and msoTrue for SaveWithDocument.
and now ,passing msoTrue for LinkToFile and msoFalse for SaveWithDocument did my job.
happy Coding..