Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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");
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"));
Original file line number Diff line number Diff line change
@@ -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();

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