Compare two presentations (C# .NET)

Hello, can we use the Equals method to compare two complete powerpoint documents?

If not, then we may try to compare the XML (or HTML) of the PPTX document to see if there are differences. However, I’d like to know if we produce the same file over and over again will the XML be exactly the same (i.e. same order of elements)? I realize that there may be some unique identifier values or dates that may change but will all elements be in the same place in the XML if there content/data (and the way we call it from code) is the same?

Thanks

@shawnt347,

I like to share that you can compare the two presentations by comparing the individual slides in two presentations. For your following point:

The presentation metadata information related to dates etc shall be updated every time you create a presentation. But as far as API is concerned, the internal mechanism of how presentation XML is managed is not exposed on application level and the documentation article that has already been shared by you can be used for comparison of slides and then eventually an entire presentation.

Thanks for the follow up. When using the Equals method to compare slides is there a way to see differences between two slides if it returns “false”?

@shawnt347,

I regret to share that there is no such feature available to list the differences of slides as there is no front end associated with API. One has to observe the difference in PowerPoint by himself to identify the difference.

@shawnt347,

The API provides you the support for comparing the presentation files, master slides, normal slides and individual slides. All you need to do is to pass two comparing objects and API will do the rest internally and will share True or False result if two different files objects are same or not.

	public static void ComaprePresentationSlides()
	{
		Presentation Src1Pres = new Presentation("Src1.pptx");
		Presentation Src2Pres = new Presentation("Src2.pptx");

		//Comparing on presentation level
		if(Src1Pres.Equals(Src2Pres))
		{
			Console.WriteLine("Two Presentation files are equal");
		}

		//Comparing Master slides
		if(Src1Pres.Masters[0].Equals(Src2Pres.Masters[0]))
		{
			Console.WriteLine("Masters are equal.");
		}

		//Comparing Layout slides
		if (Src1Pres.Masters[0].LayoutSlides[0].Equals(Src2Pres.Masters[0].LayoutSlides[0]))
		{
			Console.WriteLine("Layout are equal.");
		}

		//Comparing Normal slides
		if (Src1Pres.Slides[0].Equals(Src2Pres.Slides[0]))
		{
			Console.WriteLine("Slides are equal.");
		}

	}