diff --git a/Read-and-save-PowerPoint-presentation/Edit-PowerPoint-presentation/.NET/Edit-PowerPoint-presentation/Program.cs b/Read-and-save-PowerPoint-presentation/Edit-PowerPoint-presentation/.NET/Edit-PowerPoint-presentation/Program.cs index e9304068..a00ac25b 100644 --- a/Read-and-save-PowerPoint-presentation/Edit-PowerPoint-presentation/.NET/Edit-PowerPoint-presentation/Program.cs +++ b/Read-and-save-PowerPoint-presentation/Edit-PowerPoint-presentation/.NET/Edit-PowerPoint-presentation/Program.cs @@ -1,39 +1,40 @@ -using Syncfusion.Presentation; -using System.IO; - -//Opens the PPTX document. -using IPresentation pptxDoc = Presentation.Open(Path.GetFullPath(@"Data/Template.pptx")); - -//Get the new background picture as a stream. -using FileStream bgPictureStream = new FileStream(@"Data/Background.png", FileMode.Open); -//Create an instance for memory stream -using MemoryStream bgMemoryStream = new MemoryStream(); -//Copy stream to memoryStream. -bgPictureStream.CopyTo(bgMemoryStream); - -//Set the master slide background fill as Picture fill in PPTX document. -pptxDoc.Masters[0].Background.Fill.FillType = FillType.Picture; -pptxDoc.Masters[0].Background.Fill.PictureFill.ImageBytes = bgMemoryStream.ToArray(); - -//Get the first shape of the first slide from the PPTX document. -IShape shape = pptxDoc.Slides[0].Shapes[0] as IShape; -//Change the text of the shape. -if (shape.TextBody.Text == "Company History") - shape.TextBody.Text = "Adventure Cycles History"; - -//Get the new picture as a stream. -using FileStream pictureStream = new FileStream(@"Data/AdventureCycles.png", FileMode.Open); -//Create an instance for memory stream -using MemoryStream picMemoryStream = new MemoryStream(); -//Copy stream to memoryStream. -pictureStream.CopyTo(picMemoryStream); - -//Replace the existing image with the new image. -pptxDoc.Slides[0].Pictures[0].ImageData = picMemoryStream.ToArray(); - -//Changes the built in style of the table. -ITable table = pptxDoc.Slides[2].Tables[0]; -table.BuiltInStyle = BuiltInTableStyle.ThemedStyle2Accent5; - -//Save the PPTX document -pptxDoc.Save(@"Output/Output.pptx"); \ No newline at end of file +using Syncfusion.Presentation; +using System.IO; + + +//Opens the PPTX document. +using IPresentation pptxDoc = Presentation.Open(Path.GetFullPath(@"Data/Template.pptx")); + +//Get the new background picture as a stream. +using FileStream bgPictureStream = new FileStream(Path.GetFullPath(@"Data/Background.png"), FileMode.Open); +//Create an instance for memory stream +using MemoryStream bgMemoryStream = new MemoryStream(); +//Copy stream to memoryStream. +bgPictureStream.CopyTo(bgMemoryStream); + +//Set the master slide background fill as Picture fill in PPTX document. +pptxDoc.Masters[0].Background.Fill.FillType = FillType.Picture; +pptxDoc.Masters[0].Background.Fill.PictureFill.ImageBytes = bgMemoryStream.ToArray(); + +//Get the first shape of the first slide from the PPTX document. +IShape shape = pptxDoc.Slides[0].Shapes[0] as IShape; +//Change the text of the shape. +if (shape.TextBody.Text == "Company History") +    shape.TextBody.Text = "Adventure Cycles History"; + +//Get the new picture as a stream. +using FileStream pictureStream = new FileStream(Path.GetFullPath(@"Data/AdventureCycles.png"), FileMode.Open); +//Create an instance for memory stream +using MemoryStream picMemoryStream = new MemoryStream(); +//Copy stream to memoryStream. +pictureStream.CopyTo(picMemoryStream); + +//Replace the existing image with the new image. +pptxDoc.Slides[0].Pictures[0].ImageData = picMemoryStream.ToArray(); + +//Changes the built in style of the table. +ITable table = pptxDoc.Slides[2].Tables[0]; +table.BuiltInStyle = BuiltInTableStyle.ThemedStyle2Accent5; + +//Save the PPTX document +pptxDoc.Save(Path.GetFullPath(@"Output/Output.pptx")); \ No newline at end of file diff --git a/Sections/Split-PowerPoint-by-Sections/.NET/Split-PowerPoint-by-sections/Program.cs b/Sections/Split-PowerPoint-by-Sections/.NET/Split-PowerPoint-by-sections/Program.cs index 450bb73d..72d86db1 100644 --- a/Sections/Split-PowerPoint-by-Sections/.NET/Split-PowerPoint-by-sections/Program.cs +++ b/Sections/Split-PowerPoint-by-Sections/.NET/Split-PowerPoint-by-sections/Program.cs @@ -1,20 +1,20 @@ using Syncfusion.Presentation; -//Opens the source PPTX document. -IPresentation sourcePptx = Presentation.Open(Path.GetFullPath(@"Data/Template.pptx")); +//Opens the source PPTX document. +IPresentation sourcePptx = Presentation.Open(Path.GetFullPath(@"Data/Template.pptx")); -//Iterates through each section. -foreach (ISection section in sourcePptx.Sections) +//Iterates through each section. +foreach (ISection section in sourcePptx.Sections) { - //Creates a destination PPTX document. Existing presentations can also be used here. - IPresentation destinationPptx = Presentation.Create(); - // Clone the slides from the section and move to new PPTX document. - foreach (ISlide slide in section.Slides) - destinationPptx.Slides.Add(slide.Clone(), PasteOptions.SourceFormatting, sourcePptx); - //Saves the destination PPTX document. - destinationPptx.Save(Path.GetFullPath(@"Output/", section. Name + "_Slides.pptx")); - destinationPptx.Close(); -} -//Closes the PPTX document. -sourcePptx.Close(); - \ No newline at end of file +    //Creates a destination PPTX document. Existing presentations can also be used here. +    IPresentation destinationPptx = Presentation.Create(); +    // Clone the slides from the section and move to new PPTX document. +    foreach (ISlide slide in section.Slides) +        destinationPptx.Slides.Add(slide.Clone(), PasteOptions.SourceFormatting, sourcePptx); +    //Saves the destination PPTX document. +    string outputPath = Path.Combine(Path.GetFullPath("Output"), section.Name + "_Slides.pptx"); + destinationPptx.Save(outputPath); +    destinationPptx.Close(); +} +//Closes the PPTX document. +sourcePptx.Close(); \ No newline at end of file