When merging slides, we often have the problem that the font colors aren't the same as before. As a sample, I attached three slides. If you merge them like this...
for (int i = 0; i < presentation.Slides.LastSlidePosition; i++) { // Gets the slide slide = presentation.GetSlideByPosition(i + 1);
// Clones the slide and attaches it after the already existing slide clonedSlide = presentation.CloneSlide(slide, Presentation.Slides.LastSlidePosition + 1, Presentation, idList); }
.. the font color in the third slide of the merged file changed (see Comparision.jpg).
//source directory
string srcDir = @"D:\downloads\itcore";
//Get all the files
string[] files = Directory.GetFiles(srcDir);
//Target presentation
Presentation target = new Presentation();
//Merge slides of other presentations into target presentation
foreach (string file in files)
{
//Read the source
Presentation source = new Presentation(file);
//New idList for new source
SortedList idList = new SortedList();
//Clone all slides into target
for (int i = 1; i <= source.Slides.LastSlidePosition; i++)
{
Slide sourceSld = source.GetSlideByPosition(i);
int lastSlidePosition = target.Slides.LastSlidePosition;
source.CloneSlide(sourceSld, lastSlidePosition + 1, target, idList);
}//for
}//foreach
//Remove the first slide
target.Slides.Remove(target.GetSlideByPosition(1));
//target.DeleteUnusedMasters();
target.DeleteHandout();
//Write the output
target.Write("c:\\merged.ppt");
So it seems that DeleteUnusedMasters() deletes something which it still uses, doesn't it? Can you confirm that this is a bug in the DeleteUnusedMasters method?