Powerpoint whitespace disappearing RRS feed

  • Question

  • I'm coming across a problem where whitespace is being removed in powerpoint documents as soon as I reference a slide. The following code sample illustrates what I mean-
    //Open the document.
    using(PresentationDocument presentationDocument = PresentationDocument.Open(pptxFileName, true))
     //Just making this reference modifies the whitespace in the slide.
     Slide slide = presentationDocument.PresentationPart.SlideParts.First().Slide;
    To reproduce this issue, create a presentation with a single slide, containing a single text box with the text "[ ]" (no quotes) in it. Now, set the font of the space between the square brackets to a different color than the rest of the text. This will result in a Run containing only whitespace characters. Once the code above is run against this presentation, the line that references the slide will cause the whitespace in the Run to disappear, ultimately leaving a us with a visually changed presentation than we originally started with, even though we never explicitly changed anything- the text will now be "[]" when opened in the powerpoint application.

    In Word, the xml:space attribute can be set to 'preserve' on text elements to preserve whitespace, but it appears that there is no equivalent for Powerpoint.
    This is a critical problem in situations where whitespace is used as a key component of slide design. Has anybody figured out a workaround for this issue?

    • Edited by Sam Varden Monday, August 22, 2011 8:35 PM Formatting...
    Monday, August 22, 2011 8:33 PM