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:
c# asp.net dnn document viewer: DNN Document Viewer Control: view, annotate, redact, convert documents in dotnetnuke ASP.NET
asp.net open pdf password using c#: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#
asp.net redact pdf using c#: ASP.NET Redact PDF Document Control: redact, remove PDF text, images in web browser using C# ASP.NET
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
c# asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service
asp.net edit pdf text using c#: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net annotate pdf using c#: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#




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();