示例#1
0
        /// <summary>
        /// Adds the runs to SDT content cell.
        /// </summary>
        /// <param name="sdtContentCell">The SDT content cell.</param>
        /// <param name="runs">The runs.</param>
        private void AddRunsToSdtContentCell(SdtContentCell sdtContentCell, List <Run> runs)
        {
            TableCell cell = new TableCell();
            Paragraph para = new Paragraph();

            para.RemoveAllChildren();

            if (sdtContentCell.Descendants <ParagraphProperties>().Count() > 0)
            {
                para.ParagraphProperties = (ParagraphProperties)sdtContentCell.Descendants <ParagraphProperties>().First().Clone();
            }

            foreach (Run run in runs)
            {
                para.AppendChild <Run>(run);
            }

            cell.AppendChild <Paragraph>(para);
            SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
        }
示例#2
0
        public static void FillTextBox(this SdtContentCell content, string newText, JustificationValues alignment)
        {
            if (content != null)
            {
                // Retrieve old paragraph to get the current style of text
                Paragraph oldParagraph = content.Descendants <TableCell>().FirstOrDefault().Elements <Paragraph>().FirstOrDefault();

                // Create a new text
                var paragraph = CreateParagraph(oldParagraph, newText, alignment);

                // Replace old text with new one
                if (oldParagraph != null)
                {
                    content.Descendants <TableCell>().FirstOrDefault().ReplaceChild(paragraph, oldParagraph);
                }
                else
                {
                    content.Descendants <TableCell>().FirstOrDefault().Append(paragraph);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Adds the runs to SDT content cell.
        /// </summary>
        /// <param name="sdtContentCell">The SDT content cell.</param>
        /// <param name="runs">The runs.</param>
        private void AddRunsToSdtContentCell(SdtContentCell sdtContentCell, List<Run> runs)
        {
            TableCell cell = new TableCell();
            Paragraph para = new Paragraph();
            para.RemoveAllChildren();

            if (sdtContentCell.Descendants<ParagraphProperties>().Count() > 0)
                para.ParagraphProperties = (ParagraphProperties)sdtContentCell.Descendants<ParagraphProperties>().First().Clone();

            foreach (Run run in runs)
            {
                para.AppendChild<Run>(run);
            }

            cell.AppendChild<Paragraph>(para);
            SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
        }