none
Compare two slides

    Question

  • Sorry for my English :)

     

    I have a presentation which contains two <g class="gr_ gr_11 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="11" id="11">same </g><g class="gr_ gr_11 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" data-gr-id="11" id="11">slides</g> and now I am trying programmatically define that, but I do not know which two parameters need to compare. I tried to compare their InnerXml parameter

    public static class SlideComparer
    {
        public static bool CompareFirstAndSecondSlides(string prePath)
        {
            using (var doc = PresentationDocument.Open(prePath, false))
            {
                var slideParts = doc.PresentationPart.SlideParts.ToList();
                var firstSlideXml = slideParts[0].Slide.InnerXml;
                var secondSlideXml = slideParts[1].Slide.InnerXml;
    
                return firstSlideXml.Equals(secondSlideXml);
            }
        }
    }

    but CompareFirstAndSecondSlides() always return false despite first and second slides same by the view.

    Which parameter <g class="gr_ gr_600 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Grammar multiReplace" data-gr-id="600" id="600">need</g> to compare to define slides same or not?


    lundi 7 mai 2018 00:22

Réponses

  • Hi adamShakhabov,

    As I point out, the Slide.InnerXml presents all the content in the slide. Anything changed will make it different. 

    In your scenario, you need to enumerate all the shapes on the slide and compare the shape's property/child you cared and ignore the property/child which you doesn't want to compare like TextBody of shape object for its inter text. 

    And to check which properties/child you cared corresponding for the shape, you can create two shapes and compare them through the Open XML SDK Productivity Tool. And based on my understanding, the solution for this scenario is very complex since there are so much property and child the shape define.

    Hope it is helpful.

    Regards & Fei 

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    mardi 8 mai 2018 09:21
    Modérateur

Toutes les réponses

  • Hi adamShakhabov,

    The code in the post is just compare the xml inner slide, it will return false if there is any different based on these two xml text.

    This function should works well if the two slides are exactly same. But if you want to compare the two slides based on your business, for example if the position of a shape is a little different, you need to write your own business code to implement it.

    If you still have the problem, you may share us more detail about the scenario.

    Regards & Fei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    lundi 7 mai 2018 06:24
    Modérateur
  • But it is what I'm talking about: these slides are same, just placed in different positions on the same presentation, and still their Slide.InnerXml is different.

     A formatting and locations shapes are important for our business logic. For example, if some shapes have two different texts, but same X and Y offsets and view parameters, then they have to be considered as same.

    How to perform such compare logical? 

    lundi 7 mai 2018 21:44
  • Hi adamShakhabov,

    As I point out, the Slide.InnerXml presents all the content in the slide. Anything changed will make it different. 

    In your scenario, you need to enumerate all the shapes on the slide and compare the shape's property/child you cared and ignore the property/child which you doesn't want to compare like TextBody of shape object for its inter text. 

    And to check which properties/child you cared corresponding for the shape, you can create two shapes and compare them through the Open XML SDK Productivity Tool. And based on my understanding, the solution for this scenario is very complex since there are so much property and child the shape define.

    Hope it is helpful.

    Regards & Fei 

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    mardi 8 mai 2018 09:21
    Modérateur