When I copy a slide from presentation A and paste it into presentation B, the slide master is copied too. This is fine. However, the slide master is copied each time the slide from presentation A is pasted into presentation B. So if you copy and paste the slide 10 times, you will have 10 slide masters in presentation B. This is not correct.
Solution:
Recreate the behaviour form powerpoint if you do this manually by hand. In powerpoint, if you do this by hand, you will only have 1 slide master copied to presentation B because it must check if the slide master already exists.
To recreate the problem:
1. open both presentation A and B.
2. copy and paste the slide from presentation A into presentation B - note, ensure you select "keep source formatting"
3. copy and paste the slide 5 times. You will have 1 or 2 slide masters max.
Do the above steps by hand and by the code below and compare the difference. The powerpoint made by hand will have 2 slide masters and the powerpoint created using spire will have 3, one for each slide you append. Imaging if you append 100 slides, you will have 100 slide masters, this is not correct. This is a bug.
presentation A:
presentation B:
Spire version: This occurs in both Spire.Presentation 7.8.0 and 8.2.0
- Code: Select all
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"sample.pptx");
var finalPpt = new Presentation();
foreach (var slide in ppt.Slides)
{
var newPpt = new Presentation();
newPpt.SlideSize.Type = ppt.SlideSize.Type;
ISlide clonedSlide = ppt.Slides[0];
newPpt.Slides.Insert(0, clonedSlide);
var generatedSlide = newPpt.Slides[0];
finalPpt.Slides.Append(generatedSlide);
}
finalPpt.SaveToFile(@"C:\Users\Maine\source\repos\ConsoleApp2\ConsoleApp2\bin\Debug\net6.0\samplenew.pptx", FileFormat.Pptx2013);