C#: Online Guide
How To: powerpoint SDK
Load, Save Document
  |  
Home ›› XDoc.PowerPoint ›› C# PowerPoint: Load, Save Document

How to C#: Load, Save PowerPoint Document


Overview for How to Use XDoc.PowerPoint to load and save PowerPoint document in C# .NET Programming Project




RasterEdge XDoc.PowerPoint has provided three ways to create PowerPoint document object that are load from file, load from stream and load from byte array.Conversely, the PowerPoint SDK can also save PowerPoint document object to file, stream or byte array.


Related .net document control helps:
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net edit pdf image: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net pdf document viewer: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm...
asp.net annotate pdf: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
mvc pdf editor: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net excel web viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.




C#: Import Dlls to Run PowerPoint Document Processing for .NET



Add necessary XDoc.PowerPoint DLL libraries into your created C# application as references.


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.PowerPoint.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PowerPoint;




Load PowerPoint Document From Existing File Using C#



You may also load or create a PowerPoint document object from existing PowerPoint file in C#.net.




//  Load from a file
String inputFilePath  = Program.RootPath + "\\" + "1.pptx";
PPTXDocument doc = new PPTXDocument(inputFilePath);
if (doc == null) throw new Exception("fail to load the file");
//  ...





Load PowerPoint From Stream Object in C# Project



PowerPoint document can be loaded from a stream object in C# programming.




//  Load from a stream
String inputFilePath = Program.RootPath + "\\" + "2.pptx";
using (FileStream fileStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read))
{
    PPTXDocument doc = new PPTXDocument(fileStream);
    if (doc == null) throw new Exception("fail to load PowerPoint document from the stream");
    //  ...
}





Load PowerPoint From Byte Array Object in C# Project



PowerPoint document can be loaded from a stream object in C# programming.




//  Load from a stream
String inputFilePath = Program.RootPath + "\\" + "2.pptx";
using (FileStream fileStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read))
{
    byte[] array = new byte[fileStream.Length];
    fileStream.Read(array, 0, array.Length);
    PPTXDocument doc = new PPTXDocument(fileStream);
    if (doc == null) throw new Exception("fail to load PowerPoint document from the stream");
    //  ...
}





Save PowerPoint Document To File in C# Project



PowerPoint document can be saved to a PowerPoint file in C# programming.




String inputFilePath = Program.RootPath + "\\" + "2.pptx";
String outputFilePath = Program.RootPath + "\\" + "output.pptx";
PPTXDocument doc = new PPTXDocument(fileStream);
if (doc == null) throw new Exception("fail to load PowerPoint document from the stream");
//  Save document to a Powerpoint file
doc.Save(outputFilePath);





Save PowerPoint Document To Stream Object in C# Project



PowerPoint document can be saved to a stream object in C# programming.




String inputFilePath = Program.RootPath + "\\" + "2.pptx";
Stream stream = new MemoryStream();
PPTXDocument doc = new PPTXDocument(fileStream);
if (doc == null) throw new Exception("fail to load PowerPoint document from the stream");
//  Save document  to  a stream object
doc.SaveToStream(stream);





Save PowerPoint Document To Byte Array in C# Project



PowerPoint document can be saved to a byte array object in C# programming.




String inputFilePath = Program.RootPath + "\\" + "2.pptx";
PPTXDocument doc = new PPTXDocument(inputFilePath);
if (doc == null) throw new Exception("fail to load PowerPoint document from the stream");
//  Save document to a byte array object
byte[] array = doc.SaveToByte();