Code follows,
using (PresentationDocument presentationDocumentObj = PresentationDocument.Open(memoryStreamObj,true))
{
PresentationPart presentationPart = presentationDocument.PresentationPart;
// Check for a null document object.
if (presentationDocument == null)
{
throw new ArgumentNullException("presentationDocument");
}
// Get the Slide Id collection of the presentation document
var slideIdList = presentationPart.Presentation.SlideIdList;
if (slideIdList == null)
throw new NullReferenceException("The number of slide is empty, please select a ppt with a slide at least again");
// Get all Slide Part of the presentation document
var list = slideIdList.ChildElements.Cast<SlideId>().Select(x => presentationPart.GetPartById(x.RelationshipId)).Cast<SlidePart>();
}
The last line of code makes the power point template corrupted. my openxml version is 2.5. Any one please tell me where i'm going wrong.
- EDIT
Here is how i load the memoryStreamObj,
byte[] reportByteArray = null;
using (MemoryStream memoryStreamObj = new MemoryStream())
{
memoryStreamObj.Write(reportTemplateByteArray, 0, (int)reportTemplateByteArray.Length);
using (PresentationDocument presentationDocumentObj = PresentationDocument.Open(memoryStreamObj,true))
{
//made changes to template
}
reportByteArray = memoryStreamObj.GetBuffer();
}