我遇到一个问题,一旦我引用幻灯片,就会在powerpoint文档中删除空格.以下代码示例说明了我的意思 -
//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;
}
Run Code Online (Sandbox Code Playgroud)
要重现此问题,请使用单个幻灯片创建演示文稿,其中包含单个文本框,其中包含文本"[]"(无引号).现在,将方括号之间的空格字体设置为与文本其余部分不同的颜色.这将导致Run仅包含空格字符.一旦上面的代码针对此演示文稿运行,引用幻灯片的行将导致运行中的空白消失,最终使我们的视觉更改演示文稿比我们最初开始时,即使我们从未明确更改任何内容 - 在powerpoint应用程序中打开时,文本现在将为"[]".
在Word中,可以将xml:space属性设置为"保留"文本元素以保留空格,但似乎没有Powerpoint的等效项.
在将空白用作幻灯片设计的关键组件的情况下,这是一个关键问题.有没有人找到解决这个问题的方法?