Exemple #1
0
        private void RemoveCC(MainDocumentPart mainPart, string contentControlTag)
        {
            SdtRun contentControl = mainPart.Document.Body.Descendants <SdtRun>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == contentControlTag).SingleOrDefault();

            var breaks = contentControl.Parent.Descendants <Break>();

            foreach (var item in breaks)
            {
                item.Remove();
            }
            contentControl.Remove();
        }
Exemple #2
0
    public static Run ReplaceToRun(this SdtRun Run, string?Content = null)
    {
        var run = Run.SdtContentRun !.GetFirstChild <Run>() !;

        run.Remove();

        if (Content is not null)
        {
            run.Text(Content);
        }

        Run.InsertAfterSelf(run);
        Run.Remove();

        return(run);
    }