ApiExamples.DocumentHelper.InsertNewRun C# (CSharp) Метод

InsertNewRun() статический приватный Метод

Insert run into the current document
static private InsertNewRun ( Document doc, string text, int paraIndex ) : Run
doc Document /// Current document ///
text string /// Custom text ///
paraIndex int /// Paragraph index ///
Результат Run
        internal static Run InsertNewRun(Document doc, string text, int paraIndex)
        {
            Paragraph para = GetParagraph(doc, paraIndex);

            Run run = new Run(doc) { Text = text };

            para.AppendChild(run);

            return run;
        }

Usage Example

        public void InsertFieldAfterRunText()
        {
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            //Add some text into the paragraph
            Run run = DocumentHelper.InsertNewRun(doc, " Hello World!", 1);

            InsertFieldUsingFieldCodeFieldString(doc, " AUTHOR ", "", run, true, 1);

            Assert.AreEqual("Hello World! Hello World!\u0013 AUTHOR \u0014\u0015\r", DocumentHelper.GetParagraphText(doc, 1));
        }
All Usage Examples Of ApiExamples.DocumentHelper::InsertNewRun