How can I help you?
Load and save the Presentation
25 Jun 20269 minutes to read
Opening an existing Presentation from file system
You can open an existing PowerPoint Presentation by using the file name and its physical path.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream("Sample.pptx", FileMode.Open);
//Loads or open an PowerPoint Presentation
IPresentation pptxDoc = Presentation.Open(inputStream)//Opens an existing Presentation from file system
IPresentation pptxDoc = Presentation.Open(fileName);'Opens an existing Presentation from file system
Dim pptxDoc As IPresentation = Presentation.Open(fileName)You can download a complete working sample from GitHub.
Opening an existing Presentation from stream
You can open an existing PowerPoint Presentation from stream by using the overloads of Open method.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream(inputFileName, FileMode.Open);//Opens an existing Presentation from stream
IPresentation pptxDoc = Presentation.Open(presentationStream);'Opens an existing Presentation from stream
Dim pptxDoc As IPresentation = Presentation.Open(presentationStream)You can download a complete working sample from GitHub.
Opening an encrypted Presentation
You can open an encrypted PowerPoint presentation from either file path or stream by using the following overloads of Open method as follows.
//Opens an existing encrypted Presentation from stream
IPresentation pptxDoc = Presentation.Open(presentationStream, password);//Opens an existing encrypted Presentation from stream
IPresentation pptxDoc = Presentation.Open(presentationStream, password);'Opens an existing encrypted Presentation from stream
Dim pptxDoc As IPresentation = Presentation.Open(presentationStream, password)IPresentation pptxDoc = Presentation.Open(fileName, password);//Opens an existing encrypted Presentation from file system
IPresentation pptxDoc = Presentation.Open(fileName, password);'Opens an existing encrypted Presentation from file system
Dim pptxDoc As IPresentation = Presentation.Open(fileName, password)You can download a complete working sample from GitHub.
Saving a PowerPoint Presentation to file system
You can save the created or manipulated PowerPoint Presentation to file system by using Save() method of IPresentation interface. Default format type is *.PPTX.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream(fileName, FileMode.Open);
IPresentation pptxDoc = Presentation.Open(inputStream);
//To-Do some manipulation
FileStream outputStream = new FileStream("output.pptx", FileMode.Create);
pptxDoc.Save(outputStream);//Opens an existing PowerPoint Presentation
IPresentation pptxDoc = Presentation.Open(fileName);
//To-Do some manipulation
//Saves the Presentation in file system
pptxDoc.Save("Output.pptx");'Opens an existing PowerPoint Presentation
Dim pptxDoc As IPresentation = Presentation.Open(fileName)
'To-Do some manipulation
'Saves the Presentation in file system
pptxDoc.Save("Output.pptx")You can download a complete working sample from GitHub.
Saving a PowerPoint Presentation to stream
You can save the created or manipulated PowerPoint Presentation to stream by using overloads of Save method.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream(inputFileName, FileMode.Open);
IPresentation pptxDoc = Presentation.Open(inputStream);
//To-Do some manipulation
MemoryStream stream = new MemoryStream();
pptxDoc.Save(stream);//Opens an existing PowerPoint Presentation
IPresentation pptxDoc = Presentation.Open(fileName);
//To-Do some manipulation
//Creates an instance of memory stream
MemoryStream stream = new MemoryStream();
//Saves the Presentation to stream
pptxDoc.Save(stream);'Opens an existing PowerPoint Presentation
Dim pptxDoc As IPresentation = Presentation.Open(fileName)
'To-Do some manipulation
'Creates an instance of memory stream
Dim stream As New MemoryStream()
'Saves the Presentation to stream
pptxDoc.Save(stream)You can download a complete working sample from GitHub.
Sending to a client browser
You can save and send the Presentation to a client browser from a website or web application by invoking the overload of Save method. This method explicitly make use of an instance of HttpResponse as its parameter in order to stream the presentation to client browser. So, this overload is suitable for web application that refer to System.Web assembly.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream(inputFileName, FileMode.Open);
IPresentation pptxDoc = Presentation.Open(inputStream);
//To-Do some manipulation
//Initialize content type
string ContentType = null;
//Save the PowerPoint Presentation to stream
MemoryStream outputStream = new MemoryStream();
pptxDoc.Save(outputStream);
outputStream.Position = 0;
//Return the file with content type
return File(outputStream, ContentType, outputFileName);//Opens an existing PowerPoint Presentation
IPresentation pptxDoc = Presentation.Open(fileName);
//To-Do some manipulation
//Saves the Presentation to the client browser
pptxDoc.Save("Output.pptx", FormatType.Pptx, Response);'Opens an existing PowerPoint Presentation
Dim pptxDoc As IPresentation = Presentation.Open(fileName)
'To-Do some manipulation
'Saves the Presentation to the client browser
pptxDoc.Save("Output.pptx", FormatType.Pptx, Response)You can download a complete working sample from GitHub.
Closing a PowerPoint Presentation
When you are done with the Presentation instance, you should close the instance of IPresentation in order to release the memory consumed by Essential® Presentation library. The following code example illustrates how to close an IPresentation instance.
//Loads or open an PowerPoint Presentation
FileStream inputStream = new FileStream(inputFileName,FileMode.Open);
IPresentation pptxDoc = Presentation.Open(inputStream);
//To-Do some manipulation
//Save the PowerPoint Presentation as stream
FileStream outputStream = new FileStream(OutputFileName, FileMode.Create);
pptxDoc.Save(outputStream);
//Close the instance of PowerPoint Presentation
pptxDoc.Close();//Opens an existing Presentation from file system
IPresentation pptxDoc = Presentation.Open(fileName);
//To-Do some manipulation
//Creates an instance of memory stream
MemoryStream stream = new MemoryStream();
//Saves the Presentation to stream
pptxDoc.Save(stream);
//Closes the Presentation instance and free the memory consumed.
pptxDoc.Close();'Opens an existing Presentation from file system
Dim pptxDoc As IPresentation = Presentation.Open(fileName)
'To-Do some manipulation
'Creates an instance of memory stream
Dim stream As New MemoryStream()
'Saves the Presentation to stream
pptxDoc.Save(stream)
'Closes the Presentation instance and free the memory consumed.
pptxDoc.Close()You can download a complete working sample from GitHub.