Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Could anyone please tell me how to download an image and embed in PPT?
I tried using the below code:

C#

sFileName = ThresholdChartPath + ".jpg";
Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=SavetoPPT.ppt");
            Response.ContentType = "application/vnd.ms-powerpoint";
String imagepath = "<img src='"+ sFileName + "' width='780' height='480'/>"; 
Response.Output.Write(imagepath);                     
Response.Flush();
Response.End();

and also the code shown below:

C#

sFileName = ThresholdChartPath + ".jpg";
_powerPoint = new PowerPoint.Application();
                _presentation = _powerPoint.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoCTrue);
                int _slideNo = 0;
                _slideNo++;
                var slide = _presentation.Slides.Add(_slideNo,
                    Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
slide.Shapes.AddPicture(sFileName,Microsoft.Office.Core.MsoTriState.msoTrue,Microsoft.Office.Core.MsoTriState.msoTrue, 2, 2, 710, 530);
releaseObject(_powerPoint);
                releaseObject(_presentation);
It works fine in my local machine.
But i'm not able to download it from the server side after the website is published in the server.
Anyone please help it.

Thanks in advance.
Posted
Updated 14-Nov-12 21:45pm
v10
Comments
[no name] 15-Nov-12 3:56am    
Write to log....
skkworld 22-Nov-12 1:48am    
There is no error in log file in the server:(

1 solution

Yes, Use try , catch , And see what is the exception at Server,
There might be a possibility that Microsoft office is not installed at Server
And not able toi create PPT files

[edit]unnecesary code block removed[/edit]
 
Share this answer
 
v2
Comments
skkworld 22-Nov-12 1:40am    
I used try catch block but no exception thrown in the server.
The PPT export option works fine in the MS office version 2007 and below, but when i try to download in the system in which MS office version 2010 it shows me the following information in Event viewer "The Software Protection service has completed licensing status check. Event Id - 1003". And when i open the downloaded PPT file, it shows me an error as "Powerpoint can't read '*.ppt'".
Could You please help me to sort out the issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900