How do I add a space character to a Run or Text

Answered How do I add a space character to a Run or Text

  • 2012년 3월 12일 월요일 오후 3:11
     
     

    I tried:

    Paragraph.AppendChild(new Run(new Text("Part 1")));
    Paragraph.AppendChild(new Run(new Text(" ")));
    Paragraph.AppendChild(new Run(new Text("Part 2")));

    and the blank space does not get included into the document.  The following, by putting a space in front of the string, also does not work.

    Paragraph.AppendCHild(new Run(new Text(" Part 2")));

    How do I add a blank space?

    Thanks.

모든 응답

  • 2012년 3월 12일 월요일 오후 4:25
     
     답변됨 코드 있음

    You need to set the Text element's Space property to SpaceProcessingModeValues.Preserve:

    para.AppendChild(new Run(new Text {
        Text = " ",
        Space = SpaceProcessingModeValues.Preserve }));
    para.AppendChild(new Run(new Text {
        Text = " Spaces before and after ",
        Space = SpaceProcessingModeValues.Preserve }));
    

    Eric

    • 답변으로 제안됨 EWoodruff 2012년 3월 12일 월요일 오후 4:25
    • 답변으로 표시됨 K.Kong 2012년 3월 12일 월요일 오후 4:32
    •