C# PowerPoint Library
How to use XDoc.PowerPoint in C# application?
Overview for How to Use XDoc.PowerPoint 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.
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();