Stream PPTX to page MVC

I have a process where i take an existing pptx and remove the pages I dont need. I want to then download that pptx. I have everything working except for the download is an empty pptx.

I put in a method where it saves the newly created pptx to the file system and that one looks just fine.

Here is my code. Any help would be awesome. Thanks.


public FileResult PPT(string id, string pages)
{
return File(Merge(id, pages, SaveFormat.Pptx), System.Net.Mime.MediaTypeNames.Application.Octet, id + ".pptx");
}

public Stream Merge(string filename, string pages, SaveFormat format)
{
//License l = new License();
//l.SetLicense(Server.MapPath("/App_Data/Aspose.Slides.lic"));

List pageNumbers = pages.Split(',').Select(x => int.Parse(x)).ToList();

PresentationEx pres = new PresentationEx(Server.MapPath(string.Format("/PPT/{0}.pptx",filename)));

for (int i = 0; i < pres.Slides.Count; i++)
{
if (!pageNumbers.Contains(i))
pres.Slides.RemoveAt(i);
}

pres.Save(Server.MapPath(string.Format("/PPT/{0}.pptx", filename + DateTime.Now.ToShortDateString().Replace('/','_'))), format);

MemoryStream stream = new MemoryStream();
pres.Save(stream, format);
return stream;
}

Was able to get this fixed. The solution was to return a byte array instead of the stream.




MemoryStream stream = new MemoryStream();
pres.Save(stream, format);
return stream.ToArray();

Hi Matthew,

Thank you for considering Aspose.

We are glad that you were able to resolve the issue. Please feel free to contact support in case you need any further assistance.

Thanks & Regards,