RunProperties

We found 10 examples in language CSharp for this search. You will see 47 fragments of code.

		public void AddCards(Table table, List<StoryCard> storyCardList)
		{
			int maxY = GetY(storyCardList.Count);

			int cardsCreated = 0;
			for (int y = 0; y <= maxY; y++)
			{
				List<TableRow> currentRows = new List<TableRow>();
				int maxX = GetX(storyCardList.Count - cardsCreated);
				for (int x = 0; x < maxX; x++)
				{
					for (int rowIndex = 0; rowIndex < originalRows.Length; rowIndex++)
					{
						var row = originalRows[rowIndex];

						TableRow currentRow;
						if (x == 0)
						{
							currentRow = (TableRow)row.CloneNode(true);
							currentRow.RemoveAllChildren<TableCell>();
							currentRows.Add(currentRow);
							table.AppendChild(currentRow);
						}
						else
							currentRow = currentRows[rowIndex];

						var rowCells = originalCells[rowIndex];
						foreach (var cell in rowCells)
						{
							TableCell clonedCell = (TableCell)cell.CloneNode(true);
							currentRow.AppendChild(clonedCell);
							AddTextToBookmark(clonedCell, storyCardList[cardsCreated]);
						}
					}
					cardsCreated++;
				}
			}

			var properties = table.Descendants<TableProperties>().First();
			var oldWidth = properties.TableWidth;
			var newWidth = Convert.ToInt32(oldWidth.Width.Value) * GetX(storyCardList.Count);

			properties.TableWidth = new TableWidth { Width = newWidth.ToString(CultureInfo.InvariantCulture) };
		}

		private void AddTextToBookmark(TableCell cell, StoryCard storyCard)
		{
			var bookmark = cell.Descendants<BookmarkStart>().First();

			if (bookmark.Name == "Id")
				AppendText(storyCard.Id.ToString(), bookmark);
			else if (bookmark.Name == "Iteration")
				AppendText(storyCard.Iteration, bookmark);
			else if (bookmark.Name == "Titel")
				AppendText(storyCard.Title, bookmark);
		}

		private static void AppendText(string textValue, BookmarkStart bookmark)
		{
			var idParagraph = bookmark.Parent;

			Text text = new Text();
			text.Text = textValue;

			List<OpenXmlElement> siblings = new List<OpenXmlElement>();
			OpenXmlElement sibling = bookmark.NextSibling();
			while (sibling != null && !(sibling is BookmarkEnd))
			{
				siblings.Add(sibling);
				sibling = sibling.NextSibling();
			}

			var runSibling = bookmark.NextSibling<Run>();
			var runProperties = GetRunProperties(runSibling);

			foreach (var s in siblings)
				idParagraph.RemoveChild(s);

			var run = new Run();
			if (runProperties != null)
				run.AppendChild(runProperties);
			run.AppendChild(text);
			idParagraph.AppendChild(run);
		}

		private static RunProperties GetRunProperties(Run nextSibling)
		{
			var runProperties = nextSibling.Descendants<RunProperties>().FirstOrDefault();
			if (runProperties != null)
				runProperties = (RunProperties)runProperties.CloneNode(true);
			return runProperties;
		}

		private int GetX(int cardsLeft)
		{
			var x = cardsLeft < maxColumns ? cardsLeft : maxColumns;
			return x;
		}

		private int GetY(int cardsCount)
		{
			int maxX = GetX(cardsCount);
			var y = cardsCount / maxX;
			return y;
		}

        [TestCase("<!--<p>some text</p>-->")]
        [TestCase("<script>$.appendTo('<p>some text</p>', document);</script>")]
        public void ParseIgnore(string html)
        {
            // the inner html shouldn't be interpreted
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(0));
        }

        [Test]
        public void ParseUnclosedTag()
        {
            var elements = converter.Parse("<p>some text in <i>italics <b>,bold and italics</p>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            var runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[0].ChildElements[2].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            elements = converter.Parse("<p>First paragraph in semi-<i>italics <p>Second paragraph still italic <b>but also in bold</b></p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(2));

            runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[1].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            // this should generate a new paragraph with its own style
            elements = converter.Parse("<p>First paragraph in <i>italics </i><p>Second paragraph not in italic</p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(1));
            Assert.That(elements[1].FirstChild, Is.TypeOf(typeof(Run)));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);
        }

        [TestCase("<p>Some\ntext</p>", ExpectedResult = 1)]
        [TestCase("<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("\t<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("  <p>Some text</p> ", ExpectedResult = 1)]
        public int ParseNewline (string html)
        {
            var elements = converter.Parse(html);
            return elements[0].ChildElements.Count;
        }

        [Test]
        public void ParseDisorderedTable ()
        {
            // table parts should be reordered
            var elements = converter.Parse(@"
<table>
<tbody>
    <tr><td>Body</td></tr>
</tbody>
<thead>
    <tr><td>Header</td></tr>
</thead>
<tfoot>
    <tr><td>Footer</td></tr>
</tfoot>
</table>");

            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0], Is.TypeOf(typeof(Table)));

            var rows = elements[0].Elements<TableRow>();
            Assert.That(rows.Count(), Is.EqualTo(3));
            Assert.That(rows.ElementAt(0).InnerText, Is.EqualTo("Header"));
            Assert.That(rows.ElementAt(1).InnerText, Is.EqualTo("Body"));
            Assert.That(rows.ElementAt(2).InnerText, Is.EqualTo("Footer"));
        }

        [Test]
        public void ParseNotTag ()
        {
            var elements = converter.Parse(" < b >bold</b>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());

            elements = converter.Parse(" <3");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());
        }

        [Test]
        public void ParseNewlineFlow ()
        {
            // the new line should generate a space between "bold" and "text"
            var elements = converter.Parse(" <span>This is a <b>bold\n</b>text</span>");
        }


        [HttpPost]
        public async Task<IActionResult> GenerateDocument([FromBody] InsuranceDocumentDetails documentDetails)
        {
            try
            {

                //string filePath = Environment.CurrentDirectory + @"\\Documents\\" + documentDetails[0].clientDetails.FamilyName.ToString().Trim() + "," + documentDetails[0].clientDetails.ClientName.ToString().Trim() + "-" + documentDetails[0].clientDetails.ClientId.ToString().Trim() + ".docx";
                MemoryStream ms = new MemoryStream();
                string _storageConnection = Configuration.GetConnectionString("StorageConnectionString");
                CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(_storageConnection);
                CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
                CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("plstorage");

                if (await cloudBlobContainer.CreateIfNotExistsAsync())
                {
                    await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions
                    {
                        PublicAccess = BlobContainerPublicAccessType.Blob
                    });
                }
                string filePath = documentDetails.clientDetails.FamilyName.ToString().Trim() + "," + documentDetails.clientDetails.ClientName.ToString().Trim() + "-" + documentDetails.clientDetails.ClientId.ToString().Trim() + "-Insurance.docx";

                CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(filePath);
                using (WordprocessingDocument package = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document))
                {

                    MainDocumentPart mainPart = package.AddMainDocumentPart();
                    mainPart.Document = new Document();
                    Body body = mainPart.Document.AppendChild(new Body());
                    SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "008818E9", RsidR = "00543A0D" };
                    FooterReference footerReference1 = new FooterReference() { Type = HeaderFooterValues.Default, Id = "rId8" };

                    sectionProperties1.Append(footerReference1);

                    body.Append(sectionProperties1);





                    NumberingDefinitionsPart numberinfPart = mainPart.AddNewPart<NumberingDefinitionsPart>("numbering");
                    Numbering element = new Numbering(new AbstractNum(new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "•" }, new LevelJustification { Val = LevelJustificationValues.Left }, new ParagraphProperties(new Indentation { Left = "720", Hanging = "360" })) { LevelIndex = 0 }) { AbstractNumberId = 0 }, new NumberingInstance(new AbstractNumId() { Val = 0 }) { NumberID = 1 });
                    element.Save(numberinfPart);

                    Color orange = new Color() { Val = "ED7D27" };

                    //Your Risk Protection

                    var clientCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Client");
                    var partnerCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Partner");

                    if (clientCurrentInsurance.Count() > 0 || partnerCurrentInsurance.Count() > 0)
                    {
                        if (clientCurrentInsurance.Count() > 0)
                        {
                                  AddRiskProtection(body, documentDetails.clientDetails, clientCurrentInsurance, orange, 0);
                        }

                        if (partnerCurrentInsurance.Count() > 0)
                        {
                                     AddRiskProtection(body, documentDetails.clientDetails, partnerCurrentInsurance, orange, 1);
                        }
                    }

                    Paragraph break2 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break2);

                    //Paragraph pr0 = new Paragraph();
                    //add(pr0);
                    //body.Append(pr0);

                       GenerateBody(body);
                    Run br1 = new Run(new Break());
                    Paragraph pr1 = new Paragraph();
                    pr1.Append(new OpenXmlElement[] { br1 });
                    body.Append(pr1);

                       AddPara1(body);
                    //Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    //pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);
                        AddPara2(body);

                    //Your Insurance Needs

                    Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break3);

                    var clientNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Client");
                    var partnerNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Partner");

                    if (clientNeedsAnalysis.Count() > 0 || partnerNeedsAnalysis.Count() > 0)
                    {
                        Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Your Insurance Needs")));
                        body.Append(InsuranceNeeds);


                        if (clientNeedsAnalysis.Count() > 0)
                        {
                                AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                        }

                        if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                        {
                                  AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                        }

                    }


                    //Recommended Insurance
                    body.AppendChild(break3.CloneNode(true));
                    var clientProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Client");
                    var partnerProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Partner");

                    if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    {
                        if (clientProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, clientProposedInsurance, orange, 0);
                        }

                        if (partnerProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, partnerProposedInsurance, orange, 1);
                        }


                              AddStandardText(body, orange);
                    }

                    //Insurance ROP

                         AddReplacementOfProduct(body, documentDetails.currentInsurance, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break4);


                        AddImplementation(body, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    //Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    //body.Append(break4);


                    //if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    //{
                    //    Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Insurance replacement of product")));
                    //    body.Append(InsuranceNeeds);


                    //    if (clientNeedsAnalysis.Count() > 0)
                    //    {
                    //        AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                    //    }

                    //    if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                    //    {
                    //        AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                    //    }

                    //}

                    //Footer
                    var t = mainPart.Document.Body.Descendants<Table>().ToList();
                    var p = mainPart.Document.Body.Descendants<Paragraph>().ToList();
                    AlterTableType(t, p, package);

                    FooterPart footerPart = mainPart.AddNewPart<FooterPart>();

                    string footerPartId = mainPart.GetIdOfPart(footerPart);
                        GeneratePartContent(footerPart);

                    IEnumerable<SectionProperties> sections = mainPart.Document.Body.Elements<SectionProperties>();
                    foreach (var section in sections)
                    {
                        section.RemoveAllChildren<FooterReference>();
                        section.PrependChild<FooterReference>(new FooterReference() { Id = footerPartId });
                    }


                    package.MainDocumentPart.Document.Save();
                    package.Close();

                }


                ms.Position = 0;
                await blockBlob.UploadFromStreamAsync(ms);


                return File(ms.ToArray(), "application/octet-stream", "test");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void AddImplementation(Body body, ProposedInsuranceViewModel[] proposedInsurance, BasicDetails clientDetails, Color orange)
        {

            var implementation = new List<ProposedInsuranceViewModel>();
            var ongoing = new List<ProposedInsuranceViewModel>();

            foreach (ProposedInsuranceViewModel pI in proposedInsurance)
            {
                if (pI.Implementation.Commission > 0)
                {
                    implementation.Add(pI);
                }
                if (pI.Ongoing.Commission > 0)
                {
                    ongoing.Add(pI);
                }
            }

            if (implementation.Count() > 0 || ongoing.Count() > 0)
            {

                if (implementation.Any())
                {

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Implementation"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("If you wish to proceed with our advice, the following table shows the costs that apply to implement our recommendations."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in implementation)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }

                if (ongoing.Any())
                {

                    Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Ongoing advice"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The following table shows the ongoing costs. All fees are shown as annual amounts."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in ongoing)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }
            }


        }

        private void AddStandardText(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            r1.AppendChild(new Text("Other important information"));

            Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The recommended insurance cover may have exclusions applied, be loaded (higher premiums) or be declined depending on the outcome of underwriting."))));
            Paragraph p2 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("A death benefit will not be paid in the first 13 months of your life policy in the event of death by suicide."))));
            Paragraph p3 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Your policy has a cooling off period which allows you to cancel your cover and receive a refund of premiums paid. Please refer to the PDS for details."))));


            Paragraph s2 = body.AppendChild(new Paragraph());
            Run r2 = s2.AppendChild(new Run());
            RunProperties runProperties2 = r2.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties2.AppendChild(orange.CloneNode(true));
            r2.AppendChild(new Text("Your duty of disclosure"));

            Paragraph p5 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Before you apply for, extend, renew, vary or reinstate your insurance, it is important that you understand your duty of disclosure. The key elements are:"))));

            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You have a duty under law to disclose to the insurer every matter you know or could reasonably be expected to know that is relevant to their decision to accept your insurance application."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You must provide all the information requested by the insurer. Your duty could also extend beyond the questions in the insurance application form."))));
            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Your duty continues until the insurance application is accepted. You will need to disclose any relevant changes in your circumstances that occur before the insurance policy is issued."))));
            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("If you do not comply with your duty of disclosure, in some circumstances, your insurance may be avoided or varied, or future claims may be affected or denied. "))));

            Paragraph p6 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please refer to the relevant PDS for full details about your duty of disclosure."))));

            //Paragraph br = body.AppendChild(new Paragraph(new Run(new Break())));

            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Product Disclosure Statement of retained policies"));

            Color red = new Color() { Val = "FF0000" };

            Paragraph p7 = new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please read the following Product Disclosure Statement (PDS) for further information on your retained insurance ")));
            p7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " [policy/ies:] ", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(p7);

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[PDS name here]"))));

        }

        private void AddStandardTextROP(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            Color red = new Color() { Val = "FF0000" };
            r1.AppendChild(new Text("Product replacement recommendations"));


            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Based on our research and your needs and objectives, our recommendation is to replace your current insurance product."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Recommended product]"))));
            commentary1.Append(new Run(new RunProperties(), new Text { Text = " was deemed appropriate for you because: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If superior features]"))));
            commentary2.Append(new Run(new RunProperties(), new Text { Text = " It provides you with additional features. ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If lower premiums]"))));
            commentary3.Append(new Run(new RunProperties(), new Text { Text = " You will benefit from lower premiums. ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph commentary6 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("In making this recommendation, we compared "))));
            commentary6.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " recommended product ", Space = SpaceProcessingModeValues.Preserve }));
            commentary6.Append(new Run(new RunProperties(), new Text { Text = "to the following other products in the market: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary7 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 1]"))));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = " could ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[save you $XXX in annual costs and you would benefit from XXX features.]  ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = "However we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[you specifically stated you wanted the XXX product.] ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary8 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 2]"))));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = " offers ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[XXX features which could benefit you]", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = ", however we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[the annual costs are around $XXX more than XXX recommended product and this is more than you want to pay.] ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            // runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Important note:"));

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You should maintain your existing cover until the new policy is established, and all waiting periods are served, to ensure you have continuous cover. This could mean you are paying multiple premiums for a period of time. Once your new policy is in place and all waiting periods have been satisfied, the old policy can be cancelled."))));
            Paragraph commentary5 = new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("A policy that has been in force for three years or longer may have a greater level of protection against avoidance by an insurer if the duty of disclosure is breached or innocent misrepresentation occurs.")));
            commentary5.Append(new Run(new RunProperties(new Bold()), new Text { Text = " Cancelling your existing cover to take out new cover will restart this three year period where the insurer could avoid your policy if innocent non-disclosure or misrepresentation occurs.", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(commentary5);
        }

        private void AddRecommendedInsurance(Body body, BasicDetails clientDetails, IEnumerable<ProposedInsuranceViewModel> clientProposedInsurance, Color orange, int v)
        {
            Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));

            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));

            if (v == 0)
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.ClientName));
            }
            else
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.PartnerName));
            }


            foreach (ProposedInsuranceViewModel proposed in clientProposedInsurance)
            //New Table
            {
                Table table = body.AppendChild(new Table());
                TableProperties tableProp = new TableProperties();
                TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                tableProp.Append(tableStyle, tableWidth);
                table.AppendChild(tableProp);


                ////Header
                TableRow header = new TableRow();
                TableCell h1 = new TableCell();

                TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                ParagraphProperties hppLeft = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppCenter = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppRight = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                hppCenter.AppendChild((Justification)centerJustify.CloneNode(true));

                Justification rightJustify = new Justification() { Val = JustificationValues.Right };
                hppRight.AppendChild((Justification)rightJustify.CloneNode(true));

                Justification leftJustify = new Justification() { Val = JustificationValues.Left };

                TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                hcp.Append(hcm1, hs1, hcb);
                //hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                h1.Append(hcp);

                h1.AppendChild((ParagraphProperties)hppLeft.CloneNode(true));

                var heading = "";
                if (proposed.ReplacementId == 0)
                {
                    heading = "Purchase";
                }
                else
                {
                    heading = "";
                }

                h1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(heading))));

                TableCell h2 = new TableCell();
                h2.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h2.Append((TableCellProperties)hcp.CloneNode(true));
                h2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Provider))));

                TableCell h3 = new TableCell();
                h3.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h3.Append((TableCellProperties)hcp.CloneNode(true));
                h3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                header.Append(h1, h2, h3);

                table.Append(header);
                //Body
                TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp2 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });

                pp2.AppendChild((Justification)rightJustify.CloneNode(true));
                pp.AppendChild((Justification)leftJustify.CloneNode(true));
                tcp.Append(tcbL, tcm);
                tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));


                if (proposed.LifeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Life")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.LifeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.LifeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));



                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.LifeCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.LifeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TpdCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("TPD")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TpdCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TpdCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TpdCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TraumaCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Trauma")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TraumaCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TraumaCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TraumaCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TraumaCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }


                    if (proposed.TraumaCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.IncomeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Income Protection")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.IncomeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.IncomeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().MonthlyBenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.IncomeCover.First().MonthlyBenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WaitingPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Waiting Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WaitingPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().BenefitPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().BenefitPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }


                Run linebreak = new Run(new Break());
                Paragraph productCost = new Paragraph();
                productCost.Append(new OpenXmlElement[] { (Run)linebreak.CloneNode(true), new Run(new RunProperties(new Bold()), new Text("Please note the following: ")) });
                body.Append(productCost);

            }
        }

        private void add(Paragraph body)
        {
            AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice() { Requires = "wps" };

            W.Drawing drawing1 = new W.Drawing();

            Wp.Anchor anchor1 = new Wp.Anchor() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)114935U, DistanceFromRight = (UInt32Value)114935U, SimplePos = false, RelativeHeight = (UInt32Value)251676672U, BehindDoc = true, Locked = false, LayoutInCell = true, AllowOverlap = true, EditId = "3A313D92", AnchorId = "5438FE6E" };
            Wp.SimplePosition simplePosition1 = new Wp.SimplePosition() { X = 0L, Y = 0L };

            Wp.HorizontalPosition horizontalPosition1 = new Wp.HorizontalPosition() { RelativeFrom = Wp.HorizontalRelativePositionValues.Column };
            Wp.PositionOffset positionOffset1 = new Wp.PositionOffset();
            positionOffset1.Text = "6030595";

            horizontalPosition1.Append(positionOffset1);

            Wp.VerticalPosition verticalPosition1 = new Wp.VerticalPosition() { RelativeFrom = Wp.VerticalRelativePositionValues.Paragraph };
            Wp.PositionOffset positionOffset2 = new Wp.PositionOffset();
            positionOffset2.Text = "97155";

            verticalPosition1.Append(positionOffset2);
            Wp.Extent extent1 = new Wp.Extent() { Cx = 35560L, Cy = 13970L };
            Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 8255L, TopEdge = 5715L, RightEdge = 3810L, BottomEdge = 8890L };
            Wp.WrapNone wrapNone1 = new Wp.WrapNone();
            Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = (UInt32Value)92U, Name = "Text Box 92" };

            Wp.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Wp.NonVisualGraphicFrameDrawingProperties();

            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks();
            graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            A.Graphic graphic1 = new A.Graphic();
            graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" };

            Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape();

            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties() { TextBox = true };
            A.ShapeLocks shapeLocks1 = new A.ShapeLocks() { NoChangeArrowheads = true };

            nonVisualDrawingShapeProperties1.Append(shapeLocks1);

            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto };

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
            A.Extents extents1 = new A.Extents() { Cx = 35560L, Cy = 13970L };

            transform2D1.Append(offset1);
            transform2D1.Append(extents1);

            A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "FFFFFF" };
            A.Alpha alpha1 = new A.Alpha() { Val = 0 };

            rgbColorModelHex1.Append(alpha1);

            solidFill1.Append(rgbColorModelHex1);

            A.Outline outline1 = new A.Outline();
            A.NoFill noFill1 = new A.NoFill();

            outline1.Append(noFill1);

            A.ShapePropertiesExtensionList shapePropertiesExtensionList1 = new A.ShapePropertiesExtensionList();

            A.ShapePropertiesExtension shapePropertiesExtension1 = new A.ShapePropertiesExtension() { Uri = "{91240B29-F687-4F45-9708-019B960494DF}" };

            A14.HiddenLineProperties hiddenLineProperties1 = new A14.HiddenLineProperties() { Width = 9525 };
            hiddenLineProperties1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");

            A.SolidFill solidFill2 = new A.SolidFill();
            A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = "000000" };

            solidFill2.Append(rgbColorModelHex2);
            A.Miter miter1 = new A.Miter() { Limit = 800000 };
            A.HeadEnd headEnd1 = new A.HeadEnd();
            A.TailEnd tailEnd1 = new A.TailEnd();

            hiddenLineProperties1.Append(solidFill2);
            hiddenLineProperties1.Append(miter1);
            hiddenLineProperties1.Append(headEnd1);
            hiddenLineProperties1.Append(tailEnd1);

            shapePropertiesExtension1.Append(hiddenLineProperties1);

            shapePropertiesExtensionList1.Append(shapePropertiesExtension1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(presetGeometry1);
            shapeProperties1.Append(solidFill1);
            shapeProperties1.Append(outline1);
            shapeProperties1.Append(shapePropertiesExtensionList1);

            Wps.TextBoxInfo2 textBoxInfo21 = new Wps.TextBoxInfo2();

            W.TextBoxContent textBoxContent1 = new W.TextBoxContent();

            W.Paragraph paragraph1 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "04CE03A0", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties1 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId1 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties1 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts1 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold1 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript1 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(paragraphStyleId1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            W.Run run1 = new W.Run();

            W.RunProperties runProperties1 = new W.RunProperties();
            W.RunFonts runFonts2 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold2 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript2 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSizeComplexScript2);
            W.Text text1 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text1.Text = " ";

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            W.Paragraph paragraph2 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "6E6DB8AF", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties2 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId2 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties2 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts3 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold3 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript3 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties2.Append(runFonts3);
            paragraphMarkRunProperties2.Append(bold3);
            paragraphMarkRunProperties2.Append(fontSizeComplexScript3);

            paragraphProperties2.Append(paragraphStyleId2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            W.Run run2 = new W.Run();

            W.RunProperties runProperties2 = new W.RunProperties();
            W.RunFonts runFonts4 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold4 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript4 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(bold4);
            runProperties2.Append(fontSizeComplexScript4);
            W.Text text2 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text2.Text = " ";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);

            W.Paragraph paragraph3 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "02530E2F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties3 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId3 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties3 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts5 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold5 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript5 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties3.Append(runFonts5);
            paragraphMarkRunProperties3.Append(bold5);
            paragraphMarkRunProperties3.Append(fontSizeComplexScript5);

            paragraphProperties3.Append(paragraphStyleId3);
            paragraphProperties3.Append(paragraphMarkRunProperties3);

            W.Run run3 = new W.Run();

            W.RunProperties runProperties3 = new W.RunProperties();
            W.RunFonts runFonts6 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold6 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript6 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties3.Append(runFonts6);
            runProperties3.Append(bold6);
            runProperties3.Append(fontSizeComplexScript6);
            W.Text text3 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text3.Text = " ";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run3);

            W.Paragraph paragraph4 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4753D73F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties4 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId4 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties4 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts7 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold7 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript7 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties4.Append(runFonts7);
            paragraphMarkRunProperties4.Append(bold7);
            paragraphMarkRunProperties4.Append(fontSizeComplexScript7);

            paragraphProperties4.Append(paragraphStyleId4);
            paragraphProperties4.Append(paragraphMarkRunProperties4);

            paragraph4.Append(paragraphProperties4);

            W.Paragraph paragraph5 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7675723D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties5 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId5 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties5 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts8 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold8 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript8 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties5.Append(runFonts8);
            paragraphMarkRunProperties5.Append(bold8);
            paragraphMarkRunProperties5.Append(fontSizeComplexScript8);

            paragraphProperties5.Append(paragraphStyleId5);
            paragraphProperties5.Append(paragraphMarkRunProperties5);

            W.Run run4 = new W.Run();

            W.RunProperties runProperties4 = new W.RunProperties();
            W.RunFonts runFonts9 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold9 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript9 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties4.Append(runFonts9);
            runProperties4.Append(bold9);
            runProperties4.Append(fontSizeComplexScript9);
            W.Text text4 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text4.Text = " ";

            run4.Append(runProperties4);
            run4.Append(text4);

            paragraph5.Append(paragraphProperties5);
            paragraph5.Append(run4);

            W.Paragraph paragraph6 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "12AC83A7", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties6 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId6 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties6 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts10 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold10 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript10 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties6.Append(runFonts10);
            paragraphMarkRunProperties6.Append(bold10);
            paragraphMarkRunProperties6.Append(fontSizeComplexScript10);

            paragraphProperties6.Append(paragraphStyleId6);
            paragraphProperties6.Append(paragraphMarkRunProperties6);

            W.Run run5 = new W.Run();

            W.RunProperties runProperties5 = new W.RunProperties();
            W.RunFonts runFonts11 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold11 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript11 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties5.Append(runFonts11);
            runProperties5.Append(bold11);
            runProperties5.Append(fontSizeComplexScript11);
            W.Text text5 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text5.Text = " ";

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph6.Append(paragraphProperties6);
            paragraph6.Append(run5);

            W.Paragraph paragraph7 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7F4349F2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties7 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId7 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties7 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts12 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold12 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript12 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties7.Append(runFonts12);
            paragraphMarkRunProperties7.Append(bold12);
            paragraphMarkRunProperties7.Append(fontSizeComplexScript12);

            paragraphProperties7.Append(paragraphStyleId7);
            paragraphProperties7.Append(paragraphMarkRunProperties7);

            W.Run run6 = new W.Run();

            W.RunProperties runProperties6 = new W.RunProperties();
            W.RunFonts runFonts13 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold13 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript13 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties6.Append(runFonts13);
            runProperties6.Append(bold13);
            runProperties6.Append(fontSizeComplexScript13);
            W.Text text6 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text6.Text = " ";

            run6.Append(runProperties6);
            run6.Append(text6);

            paragraph7.Append(paragraphProperties7);
            paragraph7.Append(run6);

            W.Paragraph paragraph8 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5378D687", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties8 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId8 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties8 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts14 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold14 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript14 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties8.Append(runFonts14);
            paragraphMarkRunProperties8.Append(bold14);
            paragraphMarkRunProperties8.Append(fontSizeComplexScript14);

            paragraphProperties8.Append(paragraphStyleId8);
            paragraphProperties8.Append(paragraphMarkRunProperties8);

            W.Run run7 = new W.Run();

            W.RunProperties runProperties7 = new W.RunProperties();
            W.RunFonts runFonts15 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold15 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript15 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties7.Append(runFonts15);
            runProperties7.Append(bold15);
            runProperties7.Append(fontSizeComplexScript15);
            W.Text text7 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text7.Text = " ";

            run7.Append(runProperties7);
            run7.Append(text7);

            paragraph8.Append(paragraphProperties8);
            paragraph8.Append(run7);

            W.Paragraph paragraph9 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5DCADE92", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties9 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId9 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties9 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts16 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold16 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript16 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties9.Append(runFonts16);
            paragraphMarkRunProperties9.Append(bold16);
            paragraphMarkRunProperties9.Append(fontSizeComplexScript16);

            paragraphProperties9.Append(paragraphStyleId9);
            paragraphProperties9.Append(paragraphMarkRunProperties9);

            W.Run run8 = new W.Run();

            W.RunProperties runProperties8 = new W.RunProperties();
            W.RunFonts runFonts17 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold17 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript17 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties8.Append(runFonts17);
            runProperties8.Append(bold17);
            runProperties8.Append(fontSizeComplexScript17);
            W.Text text8 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text8.Text = " ";

            run8.Append(runProperties8);
            run8.Append(text8);

            paragraph9.Append(paragraphProperties9);
            paragraph9.Append(run8);

            W.Paragraph paragraph10 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4AC96599", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties10 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId10 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties10 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts18 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold18 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript18 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties10.Append(runFonts18);
            paragraphMarkRunProperties10.Append(bold18);
            paragraphMarkRunProperties10.Append(fontSizeComplexScript18);

            paragraphProperties10.Append(paragraphStyleId10);
            paragraphProperties10.Append(paragraphMarkRunProperties10);

            W.Run run9 = new W.Run();

            W.RunProperties runProperties9 = new W.RunProperties();
            W.RunFonts runFonts19 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold19 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript19 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties9.Append(runFonts19);
            runProperties9.Append(bold19);
            runProperties9.Append(fontSizeComplexScript19);
            W.Text text9 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text9.Text = " ";

            run9.Append(runProperties9);
            run9.Append(text9);

            paragraph10.Append(paragraphProperties10);
            paragraph10.Append(run9);

            W.Paragraph paragraph11 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "2B4B8144", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties11 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId11 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties11 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts20 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold20 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript20 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties11.Append(runFonts20);
            paragraphMarkRunProperties11.Append(bold20);
            paragraphMarkRunProperties11.Append(fontSizeComplexScript20);

            paragraphProperties11.Append(paragraphStyleId11);
            paragraphProperties11.Append(paragraphMarkRunProperties11);

            W.Run run10 = new W.Run();

            W.RunProperties runProperties10 = new W.RunProperties();
            W.RunFonts runFonts21 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold21 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript21 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties10.Append(runFonts21);
            runProperties10.Append(bold21);
            runProperties10.Append(fontSizeComplexScript21);
            W.Text text10 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text10.Text = " ";

            run10.Append(runProperties10);
            run10.Append(text10);

            paragraph11.Append(paragraphProperties11);
            paragraph11.Append(run10);

            W.Paragraph paragraph12 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "0AAAC9A6", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties12 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId12 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties12 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts22 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold22 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript22 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties12.Append(runFonts22);
            paragraphMarkRunProperties12.Append(bold22);
            paragraphMarkRunProperties12.Append(fontSizeComplexScript22);

            paragraphProperties12.Append(paragraphStyleId12);
            paragraphProperties12.Append(paragraphMarkRunProperties12);

            W.Run run11 = new W.Run();

            W.RunProperties runProperties11 = new W.RunProperties();
            W.RunFonts runFonts23 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold23 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript23 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties11.Append(runFonts23);
            runProperties11.Append(bold23);
            runProperties11.Append(fontSizeComplexScript23);
            W.Text text11 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text11.Text = " ";

            run11.Append(runProperties11);
            run11.Append(text11);

            paragraph12.Append(paragraphProperties12);
            paragraph12.Append(run11);

            W.Paragraph paragraph13 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5506A4C5", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties13 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId13 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties13 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts24 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold24 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript24 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties13.Append(runFonts24);
            paragraphMarkRunProperties13.Append(bold24);
            paragraphMarkRunProperties13.Append(fontSizeComplexScript24);

            paragraphProperties13.Append(paragraphStyleId13);
            paragraphProperties13.Append(paragraphMarkRunProperties13);

            W.Run run12 = new W.Run();

            W.RunProperties runProperties12 = new W.RunProperties();
            W.RunFonts runFonts25 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold25 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript25 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties12.Append(runFonts25);
            runProperties12.Append(bold25);
            runProperties12.Append(fontSizeComplexScript25);
            W.Text text12 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text12.Text = " ";

            run12.Append(runProperties12);
            run12.Append(text12);

            paragraph13.Append(paragraphProperties13);
            paragraph13.Append(run12);

            W.Paragraph paragraph14 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7AEBEDA2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties14 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId14 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties14 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts26 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold26 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript26 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties14.Append(runFonts26);
            paragraphMarkRunProperties14.Append(bold26);
            paragraphMarkRunProperties14.Append(fontSizeComplexScript26);

            paragraphProperties14.Append(paragraphStyleId14);
            paragraphProperties14.Append(paragraphMarkRunProperties14);

            W.Run run13 = new W.Run();

            W.RunProperties runProperties13 = new W.RunProperties();
            W.RunFonts runFonts27 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold27 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript27 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties13.Append(runFonts27);
            runProperties13.Append(bold27);
            runProperties13.Append(fontSizeComplexScript27);
            W.Text text13 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text13.Text = " ";

            run13.Append(runProperties13);
            run13.Append(text13);

            paragraph14.Append(paragraphProperties14);
            paragraph14.Append(run13);

            W.Paragraph paragraph15 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "48085869", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties15 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId15 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties15 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts28 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold28 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript28 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties15.Append(runFonts28);
            paragraphMarkRunProperties15.Append(bold28);
            paragraphMarkRunProperties15.Append(fontSizeComplexScript28);

            paragraphProperties15.Append(paragraphStyleId15);
            paragraphProperties15.Append(paragraphMarkRunProperties15);

            paragraph15.Append(paragraphProperties15);

            W.Paragraph paragraph16 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "03349807", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties16 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId16 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties16 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts29 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold29 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript29 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties16.Append(runFonts29);
            paragraphMarkRunProperties16.Append(bold29);
            paragraphMarkRunProperties16.Append(fontSizeComplexScript29);

            paragraphProperties16.Append(paragraphStyleId16);
            paragraphProperties16.Append(paragraphMarkRunProperties16);

            W.Run run14 = new W.Run();

            W.RunProperties runProperties14 = new W.RunProperties();
            W.RunFonts runFonts30 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold30 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript30 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties14.Append(runFonts30);
            runProperties14.Append(bold30);
            runProperties14.Append(fontSizeComplexScript30);
            W.Text text14 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text14.Text = " ";

            run14.Append(runProperties14);
            run14.Append(text14);

            paragraph16.Append(paragraphProperties16);
            paragraph16.Append(run14);

            W.Paragraph paragraph17 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "13B8FCE4", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties17 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId17 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties17 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts31 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold31 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript31 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties17.Append(runFonts31);
            paragraphMarkRunProperties17.Append(bold31);
            paragraphMarkRunProperties17.Append(fontSizeComplexScript31);

            paragraphProperties17.Append(paragraphStyleId17);
            paragraphProperties17.Append(paragraphMarkRunProperties17);

            paragraph17.Append(paragraphProperties17);

            W.Paragraph paragraph18 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3ACA8116", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties18 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId18 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties18 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts32 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold32 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript32 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties18.Append(runFonts32);
            paragraphMarkRunProperties18.Append(bold32);
            paragraphMarkRunProperties18.Append(fontSizeComplexScript32);

            paragraphProperties18.Append(paragraphStyleId18);
            paragraphProperties18.Append(paragraphMarkRunProperties18);

            W.Run run15 = new W.Run();

            W.RunProperties runProperties15 = new W.RunProperties();
            W.RunFonts runFonts33 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold33 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript33 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties15.Append(runFonts33);
            runProperties15.Append(bold33);
            runProperties15.Append(fontSizeComplexScript33);
            W.Text text15 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text15.Text = " ";

            run15.Append(runProperties15);
            run15.Append(text15);

            paragraph18.Append(paragraphProperties18);
            paragraph18.Append(run15);

            W.Paragraph paragraph19 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "05C6F3B3", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties19 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId19 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties19 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts34 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold34 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript34 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties19.Append(runFonts34);
            paragraphMarkRunProperties19.Append(bold34);
            paragraphMarkRunProperties19.Append(fontSizeComplexScript34);

            paragraphProperties19.Append(paragraphStyleId19);
            paragraphProperties19.Append(paragraphMarkRunProperties19);

            W.Run run16 = new W.Run();

            W.RunProperties runProperties16 = new W.RunProperties();
            W.RunFonts runFonts35 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold35 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript35 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties16.Append(runFonts35);
            runProperties16.Append(bold35);
            runProperties16.Append(fontSizeComplexScript35);
            W.Text text16 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text16.Text = " ";

            run16.Append(runProperties16);
            run16.Append(text16);

            paragraph19.Append(paragraphProperties19);
            paragraph19.Append(run16);

            W.Paragraph paragraph20 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3C7FD12D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties20 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId20 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties20 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts36 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold36 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript36 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties20.Append(runFonts36);
            paragraphMarkRunProperties20.Append(bold36);
            paragraphMarkRunProperties20.Append(fontSizeComplexScript36);

            paragraphProperties20.Append(paragraphStyleId20);
            paragraphProperties20.Append(paragraphMarkRunProperties20);

            paragraph20.Append(paragraphProperties20);

            textBoxContent1.Append(paragraph1);
            textBoxContent1.Append(paragraph2);
            textBoxContent1.Append(paragraph3);
            textBoxContent1.Append(paragraph4);
            textBoxContent1.Append(paragraph5);
            textBoxContent1.Append(paragraph6);
            textBoxContent1.Append(paragraph7);
            textBoxContent1.Append(paragraph8);
            textBoxContent1.Append(paragraph9);
            textBoxContent1.Append(paragraph10);
            textBoxContent1.Append(paragraph11);
            textBoxContent1.Append(paragraph12);
            textBoxContent1.Append(paragraph13);
            textBoxContent1.Append(paragraph14);
            textBoxContent1.Append(paragraph15);
            textBoxContent1.Append(paragraph16);
            textBoxContent1.Append(paragraph17);
            textBoxContent1.Append(paragraph18);
            textBoxContent1.Append(paragraph19);
            textBoxContent1.Append(paragraph20);

            textBoxInfo21.Append(textBoxContent1);

            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties() { Rotation = 0, Vertical = A.TextVerticalValues.Horizontal, Wrap = A.TextWrappingValues.Square, LeftInset = 0, TopInset = 0, RightInset = 0, BottomInset = 0, Anchor = A.TextAnchoringTypeValues.Top, AnchorCenter = false, UpRight = true };
            A.NoAutoFit noAutoFit1 = new A.NoAutoFit();

            textBodyProperties1.Append(noAutoFit1);

            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(textBoxInfo21);
            wordprocessingShape1.Append(textBodyProperties1);

            graphicData1.Append(wordprocessingShape1);

            graphic1.Append(graphicData1);

            Wp14.RelativeWidth relativeWidth1 = new Wp14.RelativeWidth() { ObjectId = Wp14.SizeRelativeHorizontallyValues.Page };
            Wp14.PercentageWidth percentageWidth1 = new Wp14.PercentageWidth();
            percentageWidth1.Text = "0";

            relativeWidth1.Append(percentageWidth1);

            Wp14.RelativeHeight relativeHeight1 = new Wp14.RelativeHeight() { RelativeFrom = Wp14.SizeRelativeVerticallyValues.Page };
            Wp14.PercentageHeight percentageHeight1 = new Wp14.PercentageHeight();
            percentageHeight1.Text = "0";

            relativeHeight1.Append(percentageHeight1);

            anchor1.Append(simplePosition1);
            anchor1.Append(horizontalPosition1);
            anchor1.Append(verticalPosition1);
            anchor1.Append(extent1);
            anchor1.Append(effectExtent1);
            anchor1.Append(wrapNone1);
            anchor1.Append(docProperties1);
            anchor1.Append(nonVisualGraphicFrameDrawingProperties1);
            anchor1.Append(graphic1);
            anchor1.Append(relativeWidth1);
            anchor1.Append(relativeHeight1);

            drawing1.Append(anchor1);

            //alternateContentChoice1.Append(drawing1);
            //body.Append(alternateContentChoice1);
            //body.Append(drawing1);
            Run run = new Run();
            run.AppendChild(drawing1);

            body.Append(run);

        }

        [GenericTestCase(typeof(Bold), @"<b>Bold</b>")]
        [GenericTestCase(typeof(Bold), @"<strong>Strong</strong>")]
        [GenericTestCase(typeof(Italic), @"<i>Italic</i>")]
        [GenericTestCase(typeof(Italic), @"<em>Italic</em>")]
        [GenericTestCase(typeof(Strike), @"<s>Strike</s>")]
        [GenericTestCase(typeof(Strike), @"<strike>Strike</strike>")]
        [GenericTestCase(typeof(Strike), @"<del>Del</del>")]
        [GenericTestCase(typeof(Underline), @"<u>Underline</u>")]
        [GenericTestCase(typeof(Underline), @"<ins>Inserted</ins>")]
        public void ParseHtmlElements<T> (string html) where T : OpenXmlElement
        {
            ParsePhrasing<T>(html);
        }

        [TestCase(@"<sub>Subscript</sub>", VerticalPositionValues.Subscript)]
        [TestCase(@"<sup>Superscript</sup>", VerticalPositionValues.Superscript)]
        public void ParseSubSup (string html, VerticalPositionValues val)
        {
            var textAlign = ParsePhrasing<VerticalTextAlignment>(html);
            Assert.That(textAlign.Val.HasValue, Is.EqualTo(true));
            Assert.That(textAlign.Val.Value, Is.EqualTo(val));
        }

        [Test]
        public void ParseStyle ()
        {
            var elements = converter.Parse(@"<b style=""
font-style:italic;
font-size:12px;
color:red;
text-decoration:underline;
"">bold with italic style</b>");
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.Multiple(() => {
                Assert.IsTrue(runProperties.HasChild<Bold>());
                Assert.IsTrue(runProperties.HasChild<Italic>());
                Assert.IsTrue(runProperties.HasChild<FontSize>());
                Assert.IsTrue(runProperties.HasChild<Underline>());
                Assert.IsTrue(runProperties.HasChild<Color>());
            });
        }

        /*[Test]
        public void ParseDisruptiveStyle ()
        {
            //TODO:
            // italic should not be applied as we specify font-style=normal
            var elements = converter.Parse("<i style='font-style:normal'>Not italics</i>");
            Assert.Multiple(() => {
                var runProperties = elements[0].FirstChild.GetFirstChild<RunProperties>();
                Assert.IsNotNull(runProperties);
                Assert.IsTrue(!runProperties.HasChild<Italic>());
            });

            elements = converter.Parse("<span style='font-style:italic'><i style='font-style:normal'>Not italics</i></span>");
        }*/

        [TestCase(@"<q>Build a future where people live in harmony with nature.</q>", true)]
        [TestCase(@"<cite>Build a future where people live in harmony with nature.</cite>", false)]
        public void ParseQuote(string html, bool hasQuote)
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);
            if (hasQuote)
            {
                Assert.That(run.InnerText, Is.EqualTo(" " + converter.HtmlStyles.QuoteCharacters.Prefix));

                Run lastRun = elements[0].GetLastChild<Run>();
                Assert.IsNotNull(run);
                Assert.That(lastRun.InnerText, Is.EqualTo(converter.HtmlStyles.QuoteCharacters.Suffix));

                // focus the content run
                run = (Run) run.NextSibling();
            }

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var runStyle = runProperties.GetFirstChild<RunStyle>();
            Assert.IsNotNull(runStyle);
            Assert.That(runStyle.Val.Value, Is.EqualTo("QuoteChar"));
        }

        [Test]
        public void ParseBreak()
        {
            var elements = converter.Parse(@"Lorem<br/>Ipsum");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            Assert.That(elements[0].ChildElements[0], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[1], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[2], Is.InstanceOf(typeof(Run)));
            Assert.IsNotNull(((Run)elements[0].ChildElements[1]).GetFirstChild<Break>());
        }

        private T ParsePhrasing<T> (string html) where T : OpenXmlElement
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var tag = runProperties.GetFirstChild<T>();
            Assert.IsNotNull(tag);
            return tag;
        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }


        private void Initialize(string MajorFont, string MinorFont, List<System.Drawing.Color> ThemeColors, List<System.Drawing.Color> IndexedColors)
        {
            this.MajorFont = MajorFont;
            this.MinorFont = MinorFont;

            int i;
            this.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < ThemeColors.Count; ++i)
            {
                this.listThemeColors.Add(ThemeColors[i]);
            }

            this.listIndexedColors = new List<System.Drawing.Color>();
            for (i = 0; i < IndexedColors.Count; ++i)
            {
                this.listIndexedColors.Add(IndexedColors[i]);
            }

            istrReal = new InlineString();
        }

        /// <summary>
        /// Set the text. If text formatting is needed, use one of the AppendText() functions.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void SetText(string Text)
        {
            if (Text == null || Text.Length == 0)
            {
                this.istrReal.Text = null;
            }
            else
            {
                this.istrReal.Text = new Text();
                this.istrReal.Text.Text = Text;
                if (SLTool.ToPreserveSpace(Text))
                {
                    this.istrReal.Text.Space = SpaceProcessingModeValues.Preserve;
                }
            }
        }

        /// <summary>
        /// Get the text. This is the plain text string, and not the rich text runs.
        /// </summary>
        /// <returns>The plain text.</returns>
        public string GetText()
        {
            string result = string.Empty;
            if (this.istrReal.Text != null) result = this.istrReal.Text.Text;

            return result;
        }

        /// <summary>
        /// Get a list of rich text runs.
        /// </summary>
        /// <returns>A list of rich text runs.</returns>
        public List<SLRun> GetRuns()
        {
            List<SLRun> result = new List<SLRun>();
            SLRun r;

            using (OpenXmlReader oxr = OpenXmlReader.Create(this.istrReal))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Run))
                    {
                        r = new SLRun();
                        r.FromRun((Run)oxr.LoadCurrentElement());
                        result.Add(r.Clone());
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Replace the internal list of rich text runs.
        /// </summary>
        /// <param name="Runs">The new list of rich text runs for replacing.</param>
        public void ReplaceRuns(List<SLRun> Runs)
        {
            string sText = string.Empty;
            if (this.istrReal.Text != null) sText = this.istrReal.Text.Text;

            this.istrReal.RemoveAllChildren<Text>();
            this.istrReal.RemoveAllChildren<Run>();

            int i;
            // start from the end because we're prepending to the front
            for (i = Runs.Count - 1; i >= 0; --i)
            {
                this.istrReal.PrependChild<Run>(Runs[i].ToRun());
            }

            this.SetText(sText);
        }

        /// <summary>
        /// Append given text in the current theme's minor font and default font size.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void AppendText(string Text)
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);
            font.SetFont(FontSchemeValues.Minor, SLConstants.DefaultFontSize);

            this.AppendText(Text, font);
        }


        public Run GetRun(RunProperties runProperties)
        {
            var run = new Run {RunProperties = runProperties.CloneNode()};

            if (_config.Bold.HasValue)
            {
                run.RunProperties.Bold = new Bold {Val = OnOffValue.FromBoolean(_config.Bold.Value)};
            }

            if (_config.Italic.HasValue)
            {
                run.RunProperties.Italic = new Italic {Val = OnOffValue.FromBoolean(_config.Italic.Value)};
            }

            if (_config.Underline.HasValue)
            {
                run.RunProperties.Underline = new Underline {Val = _config.Underline};
            }

            if (_config.FontSize != null)
            {
                run.RunProperties.FontSize = new FontSize{Val = _config.FontSize};
            }

            if (!string.IsNullOrEmpty(this))
            {
                var lines = ((string) this).Split(new[] {"\r\n", "\n"}, StringSplitOptions.None).AsIndexed();

                foreach (var line in lines)
                {
                    if (!line.IsFirst)
                    {
                        run.AppendChild(new Break());
                    }

                    if (!string.IsNullOrEmpty(line.Value))
                    {
                        run.AppendChild(new Text(line) {Space = SpaceProcessingModeValues.Preserve});
                    }
                }
            }

            if (_config.Value == null)
            {
                run.AppendChild(new Break());
            }

            return run;
        }

        internal Run CreateRun(WordRun wordRun)
        {
            var run = new Run();
            var runProperties = new RunProperties();

            SetHyperlink(wordRun, runProperties);
            SetBold(wordRun, runProperties);
            SetItalic(wordRun, runProperties);
            SetUnderline(wordRun, runProperties);
            SetSize(wordRun, runProperties);
            SetColor(wordRun, runProperties);

            run.AppendChild(runProperties);

            SetBreak(wordRun, run);
            SetText(wordRun, run);

            return run;
        }

        private void SetColor(WordRun wordRun, RunProperties runProperties)
        {
            if (!string.IsNullOrEmpty(wordRun.FontColor))
            {
                try
                {
                    System.Drawing.Color color = System.Drawing.Color.FromName(wordRun.FontColor);
                    string colorHex = color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
                    Color wordColor = new Color() { Val = colorHex };
                    runProperties.AppendChild(wordColor);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }

        private static void SetBreak(WordRun wordRun, Run run)
        {
            if (wordRun.InsertLineBreak)
                run.AppendChild(new Break());
        }

        private static void SetText(WordRun wordRun, Run run)
        {
            if (string.IsNullOrEmpty(wordRun.Text))
                return;

            var text = new Text { Text = wordRun.Text };

            if (wordRun.InsertSpace)
                text.Space = SpaceProcessingModeValues.Preserve;

            run.AppendChild(text);
        }

        private static void SetSize(WordRun wordRun, RunProperties runProperties)
        {
            if (wordRun.Size != 0)
                runProperties.FontSize = new FontSize { Val = new StringValue((wordRun.Size * 2).ToString()) };
        }

        private static void SetUnderline(WordRun wordRun, RunProperties runProperties)
        {
            if (wordRun.Underline && string.IsNullOrEmpty(wordRun.Uri))
                AddUnderline(runProperties);
        }

        public static void AddTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            if (genegalRules.FontStyle != null)
                runProperties.AddFontStyle(genegalRules.FontStyle);

            if (genegalRules.FontSize != 0)
                runProperties.AddFontSize(genegalRules.FontSize);

            if (genegalRules.Font != null)
                runProperties.AddFont(genegalRules.Font);
        }

        public static void AddFootNoteTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            //if (genegalRules.FootNote.FontStyle != null)
            //    runProperties.AddFontStyle(genegalRules.FootNote.FontStyle);
            if (genegalRules.FootNote != null)
            {
                if (genegalRules.FootNote.Style != null)
                    runProperties.AddFont(genegalRules.FootNote.Style);
                if (genegalRules.FootNote.Size != 0)
                    runProperties.AddFontSize(genegalRules.FootNote.Size);
            }
        }

        private static void AddFontStyle(this RunProperties runProperties, OnOffType type)
        {
            if (type is Italic)
            {
                runProperties.Italic = new Italic();
            } 
            if (type is Bold)
            {
                runProperties.Bold = new Bold();
            }
        }

        /// <summary>
        /// Размер шрифта будет в два раза меньше
        /// </summary>
        private static void AddFontSize(this RunProperties runProperties, float size)
        {
            runProperties.AppendChild(new FontSize() { Val = size.ToString()});
        }

        private static void AddFont(this RunProperties runProperties, string font)
        {
            runProperties.AppendChild(new RunFonts() { Ascii = font });
        }

        static void Main(string[] args)
        {
            WordDocument doc = new WordDocument();

            Style style1 = new Style();
            style1.ID = "Heading 1";
            style1.Name = "Heading 1";
            style1.Type = StyleType.Paragraph;
            style1.Primary = ExtendedBoolean.True;
            style1.UserInterfacePriority = 9;

            style1.ParagraphProperties.KeepNext = ExtendedBoolean.True;
            style1.ParagraphProperties.KeepLines = ExtendedBoolean.True;
            style1.ParagraphProperties.OutlineLevel = 0;

            Spacing spacing1 = new Spacing();
            spacing1.After = 0;
            spacing1.Before = 480;

            style1.ParagraphProperties.Spacing = spacing1;

            style1.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style1.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style1.RunProperties.Bold = ExtendedBoolean.True;
            style1.RunProperties.ComplexScriptBold = ExtendedBoolean.True;
            style1.RunProperties.FontSize = 28; //14 points
            style1.RunProperties.ComplexScriptFontSize = 28; //14 points
           
            Style style2 = new Style();
            style2.ID = "Title";
            style2.Name = "Title";
            style2.Type = StyleType.Paragraph;
            style2.Primary = ExtendedBoolean.True;
            style2.UserInterfacePriority = 9;
           
            BottomBorder bottomBorder = new BottomBorder(StandardBorderStyle.SingleLine);
            bottomBorder.Space = 4;
            bottomBorder.Width = 8;

            style2.ParagraphProperties.BottomBorder = bottomBorder;
            style2.ParagraphProperties.IgnoreSpace = ExtendedBoolean.True;

            Spacing spacing2 = new Spacing();
            spacing2.After = 300;
            spacing2.Line = 240;
            spacing2.LineRule = LineSpacingRule.Auto;

            style2.ParagraphProperties.Spacing = spacing2;

            style2.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style2.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style2.RunProperties.Spacing = 5;
            style2.RunProperties.FontKern = 28;
            style2.RunProperties.FontSize = 52; //26 points
            style2.RunProperties.ComplexScriptFontSize = 52; //26 points

            StyleDefinitions documentStyles = new StyleDefinitions();
            documentStyles.Styles.Add(style1);
            documentStyles.Styles.Add(style2);

            doc.StyleDefinitions = documentStyles;

            Run run1 = new Run();
            run1.AddText("Text with style \"Heading 1\"");

            Run run2 = new Run();
            run2.AddText("Text with style \"Title\"");

            Paragraph paragraph1 = new Paragraph();
            paragraph1.StyleName = "Heading 1";
            paragraph1.Add(run1);

            Paragraph paragraph2 = new Paragraph();
            paragraph2.StyleName = "Title";
            paragraph2.Add(run2);

            Paragraph emptyParagraph = new Paragraph();

            doc.Body.Add(paragraph1);
            doc.Body.Add(emptyParagraph);
            doc.Body.Add(paragraph2);

            doc.Save("c:\\test\\output.docx", true);
        }

DocumentFormat.OpenXml.Wordprocessing.RunProperties : IEnumerable

Constructors :

public RunProperties()
public RunProperties(IEnumerable<OpenXmlElement> childElements = )
public RunProperties(OpenXmlElement[] childElements = )
public RunProperties(String outerXml = )

Methods :

public Void set_Reflection(Reflection value = )
public TextOutlineEffect get_TextOutlineEffect()
public Void set_TextOutlineEffect(TextOutlineEffect value = )
public FillTextEffect get_FillTextEffect()
public Void set_FillTextEffect(FillTextEffect value = )
public Scene3D get_Scene3D()
public Void set_Scene3D(Scene3D value = )
public Properties3D get_Properties3D()
public Void set_Properties3D(Properties3D value = )
public Ligatures get_Ligatures()
public Void set_Ligatures(Ligatures value = )
public NumberingFormat get_NumberingFormat()
public Void set_NumberingFormat(NumberingFormat value = )
public NumberSpacing get_NumberSpacing()
public Void set_NumberSpacing(NumberSpacing value = )
public StylisticSets get_StylisticSets()
public Void set_StylisticSets(StylisticSets value = )
public ContextualAlternatives get_ContextualAlternatives()
public Void set_ContextualAlternatives(ContextualAlternatives value = )
public RunPropertiesChange get_RunPropertiesChange()
public Void set_RunPropertiesChange(RunPropertiesChange value = )
public OpenXmlElement CloneNode(Boolean deep = )
public RunStyle get_RunStyle()
public Void set_RunStyle(RunStyle value = )
public RunFonts get_RunFonts()
public Void set_RunFonts(RunFonts value = )
public Bold get_Bold()
public Void set_Bold(Bold value = )
public BoldComplexScript get_BoldComplexScript()
public Void set_BoldComplexScript(BoldComplexScript value = )
public Italic get_Italic()
public Void set_Italic(Italic value = )
public ItalicComplexScript get_ItalicComplexScript()
public Void set_ItalicComplexScript(ItalicComplexScript value = )
public Caps get_Caps()
public Void set_Caps(Caps value = )
public SmallCaps get_SmallCaps()
public Void set_SmallCaps(SmallCaps value = )
public Strike get_Strike()
public Void set_Strike(Strike value = )
public DoubleStrike get_DoubleStrike()
public Void set_DoubleStrike(DoubleStrike value = )
public Outline get_Outline()
public Void set_Outline(Outline value = )
public Shadow get_Shadow()
public Void set_Shadow(Shadow value = )
public Emboss get_Emboss()
public Void set_Emboss(Emboss value = )
public Imprint get_Imprint()
public Void set_Imprint(Imprint value = )
public NoProof get_NoProof()
public Void set_NoProof(NoProof value = )
public SnapToGrid get_SnapToGrid()
public Void set_SnapToGrid(SnapToGrid value = )
public Vanish get_Vanish()
public Void set_Vanish(Vanish value = )
public WebHidden get_WebHidden()
public Void set_WebHidden(WebHidden value = )
public Color get_Color()
public Void set_Color(Color value = )
public Spacing get_Spacing()
public Void set_Spacing(Spacing value = )
public CharacterScale get_CharacterScale()
public Void set_CharacterScale(CharacterScale value = )
public Kern get_Kern()
public Void set_Kern(Kern value = )
public Position get_Position()
public Void set_Position(Position value = )
public FontSize get_FontSize()
public Void set_FontSize(FontSize value = )
public FontSizeComplexScript get_FontSizeComplexScript()
public Void set_FontSizeComplexScript(FontSizeComplexScript value = )
public Highlight get_Highlight()
public Void set_Highlight(Highlight value = )
public Underline get_Underline()
public Void set_Underline(Underline value = )
public TextEffect get_TextEffect()
public Void set_TextEffect(TextEffect value = )
public Border get_Border()
public Void set_Border(Border value = )
public Shading get_Shading()
public Void set_Shading(Shading value = )
public FitText get_FitText()
public Void set_FitText(FitText value = )
public VerticalTextAlignment get_VerticalTextAlignment()
public Void set_VerticalTextAlignment(VerticalTextAlignment value = )
public RightToLeftText get_RightToLeftText()
public Void set_RightToLeftText(RightToLeftText value = )
public ComplexScript get_ComplexScript()
public Void set_ComplexScript(ComplexScript value = )
public Emphasis get_Emphasis()
public Void set_Emphasis(Emphasis value = )
public Languages get_Languages()
public Void set_Languages(Languages value = )
public EastAsianLayout get_EastAsianLayout()
public Void set_EastAsianLayout(EastAsianLayout value = )
public SpecVanish get_SpecVanish()
public Void set_SpecVanish(SpecVanish value = )
public Glow get_Glow()
public Void set_Glow(Glow value = )
public Shadow get_Shadow14()
public Void set_Shadow14(Shadow value = )
public Reflection get_Reflection()
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasChildren()
public String get_InnerText()
public Void set_InnerXml(String value = )
public Boolean AddChild(OpenXmlElement newChild = , Boolean throwOnError = True)
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T child = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerXml()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

RunProperties

We found 10 examples in language CSharp for this search. You will see 37 fragments of code.

Other methods


		private static RunProperties GetRunProperties(Run nextSibling)
		{
			var runProperties = nextSibling.Descendants<RunProperties>().FirstOrDefault();
			if (runProperties != null)
				runProperties = (RunProperties)runProperties.CloneNode(true);
			return runProperties;
		}


        [Test]
        public void RunComparerHappyTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            Assert.IsTrue(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Text("Test"));
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerChildrenWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerPropertiesWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties () };
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunPropertiesComparerEmptyTest()
        {
            var a = new RunProperties();
            var b = new RunProperties();
            var runPropertiesComparer = new RunPropertiesComparer(a, b);
            Assert.IsTrue(runPropertiesComparer.Compare());
        }

        [Test]
        public void RunPropertiesComparerBNullTest()
        {
            var a = new RunProperties();
            var runPropertiesComparer = new RunPropertiesComparer(a, null);
            Assert.IsTrue(runPropertiesComparer.Compare());
        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }

        [GenericTestCase(typeof(Bold), @"<b>Bold</b>")]
        [GenericTestCase(typeof(Bold), @"<strong>Strong</strong>")]
        [GenericTestCase(typeof(Italic), @"<i>Italic</i>")]
        [GenericTestCase(typeof(Italic), @"<em>Italic</em>")]
        [GenericTestCase(typeof(Strike), @"<s>Strike</s>")]
        [GenericTestCase(typeof(Strike), @"<strike>Strike</strike>")]
        [GenericTestCase(typeof(Strike), @"<del>Del</del>")]
        [GenericTestCase(typeof(Underline), @"<u>Underline</u>")]
        [GenericTestCase(typeof(Underline), @"<ins>Inserted</ins>")]
        public void ParseHtmlElements<T> (string html) where T : OpenXmlElement
        {
            ParsePhrasing<T>(html);
        }

        [TestCase(@"<sub>Subscript</sub>", VerticalPositionValues.Subscript)]
        [TestCase(@"<sup>Superscript</sup>", VerticalPositionValues.Superscript)]
        public void ParseSubSup (string html, VerticalPositionValues val)
        {
            var textAlign = ParsePhrasing<VerticalTextAlignment>(html);
            Assert.That(textAlign.Val.HasValue, Is.EqualTo(true));
            Assert.That(textAlign.Val.Value, Is.EqualTo(val));
        }

        [Test]
        public void ParseStyle ()
        {
            var elements = converter.Parse(@"<b style=""
font-style:italic;
font-size:12px;
color:red;
text-decoration:underline;
"">bold with italic style</b>");
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.Multiple(() => {
                Assert.IsTrue(runProperties.HasChild<Bold>());
                Assert.IsTrue(runProperties.HasChild<Italic>());
                Assert.IsTrue(runProperties.HasChild<FontSize>());
                Assert.IsTrue(runProperties.HasChild<Underline>());
                Assert.IsTrue(runProperties.HasChild<Color>());
            });
        }

        /*[Test]
        public void ParseDisruptiveStyle ()
        {
            //TODO:
            // italic should not be applied as we specify font-style=normal
            var elements = converter.Parse("<i style='font-style:normal'>Not italics</i>");
            Assert.Multiple(() => {
                var runProperties = elements[0].FirstChild.GetFirstChild<RunProperties>();
                Assert.IsNotNull(runProperties);
                Assert.IsTrue(!runProperties.HasChild<Italic>());
            });

            elements = converter.Parse("<span style='font-style:italic'><i style='font-style:normal'>Not italics</i></span>");
        }*/

        [TestCase(@"<q>Build a future where people live in harmony with nature.</q>", true)]
        [TestCase(@"<cite>Build a future where people live in harmony with nature.</cite>", false)]
        public void ParseQuote(string html, bool hasQuote)
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);
            if (hasQuote)
            {
                Assert.That(run.InnerText, Is.EqualTo(" " + converter.HtmlStyles.QuoteCharacters.Prefix));

                Run lastRun = elements[0].GetLastChild<Run>();
                Assert.IsNotNull(run);
                Assert.That(lastRun.InnerText, Is.EqualTo(converter.HtmlStyles.QuoteCharacters.Suffix));

                // focus the content run
                run = (Run) run.NextSibling();
            }

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var runStyle = runProperties.GetFirstChild<RunStyle>();
            Assert.IsNotNull(runStyle);
            Assert.That(runStyle.Val.Value, Is.EqualTo("QuoteChar"));
        }

        [Test]
        public void ParseBreak()
        {
            var elements = converter.Parse(@"Lorem<br/>Ipsum");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            Assert.That(elements[0].ChildElements[0], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[1], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[2], Is.InstanceOf(typeof(Run)));
            Assert.IsNotNull(((Run)elements[0].ChildElements[1]).GetFirstChild<Break>());
        }

        private T ParsePhrasing<T> (string html) where T : OpenXmlElement
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var tag = runProperties.GetFirstChild<T>();
            Assert.IsNotNull(tag);
            return tag;
        }


        private void Initialize(string MajorFont, string MinorFont, List<System.Drawing.Color> ThemeColors, List<System.Drawing.Color> IndexedColors)
        {
            this.MajorFont = MajorFont;
            this.MinorFont = MinorFont;

            int i;
            this.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < ThemeColors.Count; ++i)
            {
                this.listThemeColors.Add(ThemeColors[i]);
            }

            this.listIndexedColors = new List<System.Drawing.Color>();
            for (i = 0; i < IndexedColors.Count; ++i)
            {
                this.listIndexedColors.Add(IndexedColors[i]);
            }

            istrReal = new InlineString();
        }

        /// <summary>
        /// Set the text. If text formatting is needed, use one of the AppendText() functions.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void SetText(string Text)
        {
            if (Text == null || Text.Length == 0)
            {
                this.istrReal.Text = null;
            }
            else
            {
                this.istrReal.Text = new Text();
                this.istrReal.Text.Text = Text;
                if (SLTool.ToPreserveSpace(Text))
                {
                    this.istrReal.Text.Space = SpaceProcessingModeValues.Preserve;
                }
            }
        }

        /// <summary>
        /// Get the text. This is the plain text string, and not the rich text runs.
        /// </summary>
        /// <returns>The plain text.</returns>
        public string GetText()
        {
            string result = string.Empty;
            if (this.istrReal.Text != null) result = this.istrReal.Text.Text;

            return result;
        }

        /// <summary>
        /// Get a list of rich text runs.
        /// </summary>
        /// <returns>A list of rich text runs.</returns>
        public List<SLRun> GetRuns()
        {
            List<SLRun> result = new List<SLRun>();
            SLRun r;

            using (OpenXmlReader oxr = OpenXmlReader.Create(this.istrReal))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Run))
                    {
                        r = new SLRun();
                        r.FromRun((Run)oxr.LoadCurrentElement());
                        result.Add(r.Clone());
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Replace the internal list of rich text runs.
        /// </summary>
        /// <param name="Runs">The new list of rich text runs for replacing.</param>
        public void ReplaceRuns(List<SLRun> Runs)
        {
            string sText = string.Empty;
            if (this.istrReal.Text != null) sText = this.istrReal.Text.Text;

            this.istrReal.RemoveAllChildren<Text>();
            this.istrReal.RemoveAllChildren<Run>();

            int i;
            // start from the end because we're prepending to the front
            for (i = Runs.Count - 1; i >= 0; --i)
            {
                this.istrReal.PrependChild<Run>(Runs[i].ToRun());
            }

            this.SetText(sText);
        }

        /// <summary>
        /// Append given text in the current theme's minor font and default font size.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void AppendText(string Text)
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);
            font.SetFont(FontSchemeValues.Minor, SLConstants.DefaultFontSize);

            this.AppendText(Text, font);
        }

        public static void AddTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            if (genegalRules.FontStyle != null)
                runProperties.AddFontStyle(genegalRules.FontStyle);

            if (genegalRules.FontSize != 0)
                runProperties.AddFontSize(genegalRules.FontSize);

            if (genegalRules.Font != null)
                runProperties.AddFont(genegalRules.Font);
        }

        public static void AddFootNoteTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            //if (genegalRules.FootNote.FontStyle != null)
            //    runProperties.AddFontStyle(genegalRules.FootNote.FontStyle);
            if (genegalRules.FootNote != null)
            {
                if (genegalRules.FootNote.Style != null)
                    runProperties.AddFont(genegalRules.FootNote.Style);
                if (genegalRules.FootNote.Size != 0)
                    runProperties.AddFontSize(genegalRules.FootNote.Size);
            }
        }

        private static void AddFontStyle(this RunProperties runProperties, OnOffType type)
        {
            if (type is Italic)
            {
                runProperties.Italic = new Italic();
            } 
            if (type is Bold)
            {
                runProperties.Bold = new Bold();
            }
        }

        /// <summary>
        /// Размер шрифта будет в два раза меньше
        /// </summary>
        private static void AddFontSize(this RunProperties runProperties, float size)
        {
            runProperties.AppendChild(new FontSize() { Val = size.ToString()});
        }

        private static void AddFont(this RunProperties runProperties, string font)
        {
            runProperties.AppendChild(new RunFonts() { Ascii = font });
        }

        static void Main(string[] args)
        {
            WordDocument doc = new WordDocument();

            Style style1 = new Style();
            style1.ID = "Heading 1";
            style1.Name = "Heading 1";
            style1.Type = StyleType.Paragraph;
            style1.Primary = ExtendedBoolean.True;
            style1.UserInterfacePriority = 9;

            style1.ParagraphProperties.KeepNext = ExtendedBoolean.True;
            style1.ParagraphProperties.KeepLines = ExtendedBoolean.True;
            style1.ParagraphProperties.OutlineLevel = 0;

            Spacing spacing1 = new Spacing();
            spacing1.After = 0;
            spacing1.Before = 480;

            style1.ParagraphProperties.Spacing = spacing1;

            style1.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style1.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style1.RunProperties.Bold = ExtendedBoolean.True;
            style1.RunProperties.ComplexScriptBold = ExtendedBoolean.True;
            style1.RunProperties.FontSize = 28; //14 points
            style1.RunProperties.ComplexScriptFontSize = 28; //14 points
           
            Style style2 = new Style();
            style2.ID = "Title";
            style2.Name = "Title";
            style2.Type = StyleType.Paragraph;
            style2.Primary = ExtendedBoolean.True;
            style2.UserInterfacePriority = 9;
           
            BottomBorder bottomBorder = new BottomBorder(StandardBorderStyle.SingleLine);
            bottomBorder.Space = 4;
            bottomBorder.Width = 8;

            style2.ParagraphProperties.BottomBorder = bottomBorder;
            style2.ParagraphProperties.IgnoreSpace = ExtendedBoolean.True;

            Spacing spacing2 = new Spacing();
            spacing2.After = 300;
            spacing2.Line = 240;
            spacing2.LineRule = LineSpacingRule.Auto;

            style2.ParagraphProperties.Spacing = spacing2;

            style2.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style2.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style2.RunProperties.Spacing = 5;
            style2.RunProperties.FontKern = 28;
            style2.RunProperties.FontSize = 52; //26 points
            style2.RunProperties.ComplexScriptFontSize = 52; //26 points

            StyleDefinitions documentStyles = new StyleDefinitions();
            documentStyles.Styles.Add(style1);
            documentStyles.Styles.Add(style2);

            doc.StyleDefinitions = documentStyles;

            Run run1 = new Run();
            run1.AddText("Text with style \"Heading 1\"");

            Run run2 = new Run();
            run2.AddText("Text with style \"Title\"");

            Paragraph paragraph1 = new Paragraph();
            paragraph1.StyleName = "Heading 1";
            paragraph1.Add(run1);

            Paragraph paragraph2 = new Paragraph();
            paragraph2.StyleName = "Title";
            paragraph2.Add(run2);

            Paragraph emptyParagraph = new Paragraph();

            doc.Body.Add(paragraph1);
            doc.Body.Add(emptyParagraph);
            doc.Body.Add(paragraph2);

            doc.Save("c:\\test\\output.docx", true);
        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }

        public static OpenXmlElement Convert(Paragraph paragraph,
                                             WordprocessingDocument document,
                                             int? defaultFontSize = null)
        {
            var docxParagraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
            var parameters = paragraph.Parameters;

            var paragraphProperties = new ParagraphProperties();

            if (parameters.Alignment.HasValue)
                paragraphProperties.Justification = new Justification { Val = GetJustificationValues(parameters.Alignment.Value) };

            if (parameters.SpaceBetweenLines.HasValue)
                paragraphProperties.SpacingBetweenLines = new SpacingBetweenLines
                                                          {
                                                              LineRule = LineSpacingRuleValues.Auto,
                                                              Line = (240 * parameters.SpaceBetweenLines.Value).ToString()
                                                          };

            var runProperties = new RunProperties();
            if (parameters.Bold)
                runProperties.Bold = new Bold();

            var fontSize = parameters.FontSize ?? defaultFontSize;
            if (fontSize.HasValue)
            {
                var rPr = new ParagraphMarkRunProperties(new FontSize { Val = (fontSize.Value * 2).ToString() },
                                                         new FontSizeComplexScript { Val = (fontSize.Value * 2).ToString() });
                paragraphProperties.AppendChild(rPr);
                runProperties.FontSize = new FontSize { Val = (fontSize.Value * 2).ToString() };
                runProperties.FontSizeComplexScript = new FontSizeComplexScript { Val = (fontSize.Value * 2).ToString() };
            }

            var defaultFont = FontFamily.GenericSansSerif.Name;
            runProperties.RunFonts = new RunFonts
                                     {
                                         Ascii = defaultFont,
                                         ComplexScript = defaultFont,
                                         HighAnsi = defaultFont
                                     };

            if (parameters.BackgroundColor.HasValue)
                runProperties.Shading = new Shading
                                        {
                                            Val = ShadingPatternValues.Clear,
                                            Color = "auto",
                                            Fill = parameters.BackgroundColor.Value.ToHex()
                                        };

            foreach (var run in parameters.Parts.Select(x => GetRun(document, x, runProperties)))
                docxParagraph.AppendChild(run);
            docxParagraph.ParagraphProperties = paragraphProperties;
            return docxParagraph;
        }

        private static Run GetRun(WordprocessingDocument document,
                                  Part part,
                                  RunProperties properties)
        {
            var run = new Run { RunProperties = properties.CloneNode<RunProperties>(true) };

            var textPart = part as TextPart;
            if (textPart != null)
            {
                if (textPart.Text == null)
                    return run;

                var lines = textPart.Text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
                for (var i = 0; i < lines.Length; i++)
                {
                    if (i > 0)
                        run.AppendChild(new Break());
                    if (!string.IsNullOrEmpty(lines[i]))
                        run.AppendChild(new Text(lines[i]) { Space = SpaceProcessingModeValues.Preserve });
                }

                return run;
            }

            var fieldPart = part as FieldPart;
            if (fieldPart != null)
            {
                run.AppendChild(new SimpleField { Instruction = GetInsructionForField(fieldPart.Field) });
                return run;
            }

            var picturePart = part as PicturePart;
            if (picturePart != null)
            {
                if (picturePart.Picture?.IsEmpty() == false)
                    run.AppendChild(PictureConverter.Convert(picturePart.Picture, document));
                return run;
            }

            var stubPicturePart = part as StubPicturePart;
            if (stubPicturePart != null)
            {
                if (stubPicturePart.StubPicture != null)
                    run.AppendChild(PictureConverter.Convert(stubPicturePart.StubPicture, document));
                return run;
            }

            throw new InvalidOperationException($"Can't process part of paragraph with type {part.GetType().FullName}");
        }

        private static JustificationValues GetJustificationValues(Alignment alignment)
        {
            switch (alignment)
            {
                case Alignment.Left:
                    return JustificationValues.Left;
                case Alignment.Center:
                    return JustificationValues.Center;
                case Alignment.Right:
                    return JustificationValues.Right;
                case Alignment.Both:
                    return JustificationValues.Both;
                default:
                    throw new ArgumentOutOfRangeException(nameof(alignment), alignment, null);
            }
        }

        private static string GetInsructionForField(Field field)
        {
            switch (field)
            {
                case Field.PageNumber:
                    return " PAGE   \\* MERGEFORMAT ";
                case Field.PageCount:
                    return " NUMPAGES   \\* MERGEFORMAT ";
                default:
                    throw new ArgumentOutOfRangeException(nameof(field), field, null);
            }
        }

DocumentFormat.OpenXml.Spreadsheet.RunProperties : IEnumerable

Constructors :

public RunProperties()
public RunProperties(IEnumerable<OpenXmlElement> childElements = )
public RunProperties(OpenXmlElement[] childElements = )
public RunProperties(String outerXml = )

Methods :

public OpenXmlElement CloneNode(Boolean deep = )
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasChildren()
public String get_InnerText()
public Void set_InnerXml(String value = )
public Boolean AddChild(OpenXmlElement newChild = , Boolean throwOnError = True)
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T child = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerXml()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

RunProperties

We found 10 examples in language CSharp for this search. You will see 45 fragments of code.

		public void AddCards(Table table, List<StoryCard> storyCardList)
		{
			int maxY = GetY(storyCardList.Count);

			int cardsCreated = 0;
			for (int y = 0; y <= maxY; y++)
			{
				List<TableRow> currentRows = new List<TableRow>();
				int maxX = GetX(storyCardList.Count - cardsCreated);
				for (int x = 0; x < maxX; x++)
				{
					for (int rowIndex = 0; rowIndex < originalRows.Length; rowIndex++)
					{
						var row = originalRows[rowIndex];

						TableRow currentRow;
						if (x == 0)
						{
							currentRow = (TableRow)row.CloneNode(true);
							currentRow.RemoveAllChildren<TableCell>();
							currentRows.Add(currentRow);
							table.AppendChild(currentRow);
						}
						else
							currentRow = currentRows[rowIndex];

						var rowCells = originalCells[rowIndex];
						foreach (var cell in rowCells)
						{
							TableCell clonedCell = (TableCell)cell.CloneNode(true);
							currentRow.AppendChild(clonedCell);
							AddTextToBookmark(clonedCell, storyCardList[cardsCreated]);
						}
					}
					cardsCreated++;
				}
			}

			var properties = table.Descendants<TableProperties>().First();
			var oldWidth = properties.TableWidth;
			var newWidth = Convert.ToInt32(oldWidth.Width.Value) * GetX(storyCardList.Count);

			properties.TableWidth = new TableWidth { Width = newWidth.ToString(CultureInfo.InvariantCulture) };
		}

		private void AddTextToBookmark(TableCell cell, StoryCard storyCard)
		{
			var bookmark = cell.Descendants<BookmarkStart>().First();

			if (bookmark.Name == "Id")
				AppendText(storyCard.Id.ToString(), bookmark);
			else if (bookmark.Name == "Iteration")
				AppendText(storyCard.Iteration, bookmark);
			else if (bookmark.Name == "Titel")
				AppendText(storyCard.Title, bookmark);
		}

		private static void AppendText(string textValue, BookmarkStart bookmark)
		{
			var idParagraph = bookmark.Parent;

			Text text = new Text();
			text.Text = textValue;

			List<OpenXmlElement> siblings = new List<OpenXmlElement>();
			OpenXmlElement sibling = bookmark.NextSibling();
			while (sibling != null && !(sibling is BookmarkEnd))
			{
				siblings.Add(sibling);
				sibling = sibling.NextSibling();
			}

			var runSibling = bookmark.NextSibling<Run>();
			var runProperties = GetRunProperties(runSibling);

			foreach (var s in siblings)
				idParagraph.RemoveChild(s);

			var run = new Run();
			if (runProperties != null)
				run.AppendChild(runProperties);
			run.AppendChild(text);
			idParagraph.AppendChild(run);
		}

		private static RunProperties GetRunProperties(Run nextSibling)
		{
			var runProperties = nextSibling.Descendants<RunProperties>().FirstOrDefault();
			if (runProperties != null)
				runProperties = (RunProperties)runProperties.CloneNode(true);
			return runProperties;
		}

		private int GetX(int cardsLeft)
		{
			var x = cardsLeft < maxColumns ? cardsLeft : maxColumns;
			return x;
		}

		private int GetY(int cardsCount)
		{
			int maxX = GetX(cardsCount);
			var y = cardsCount / maxX;
			return y;
		}

        [TestCase("<!--<p>some text</p>-->")]
        [TestCase("<script>$.appendTo('<p>some text</p>', document);</script>")]
        public void ParseIgnore(string html)
        {
            // the inner html shouldn't be interpreted
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(0));
        }

        [Test]
        public void ParseUnclosedTag()
        {
            var elements = converter.Parse("<p>some text in <i>italics <b>,bold and italics</p>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            var runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[0].ChildElements[2].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            elements = converter.Parse("<p>First paragraph in semi-<i>italics <p>Second paragraph still italic <b>but also in bold</b></p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(2));

            runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[1].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            // this should generate a new paragraph with its own style
            elements = converter.Parse("<p>First paragraph in <i>italics </i><p>Second paragraph not in italic</p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(1));
            Assert.That(elements[1].FirstChild, Is.TypeOf(typeof(Run)));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);
        }

        [TestCase("<p>Some\ntext</p>", ExpectedResult = 1)]
        [TestCase("<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("\t<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("  <p>Some text</p> ", ExpectedResult = 1)]
        public int ParseNewline (string html)
        {
            var elements = converter.Parse(html);
            return elements[0].ChildElements.Count;
        }

        [Test]
        public void ParseDisorderedTable ()
        {
            // table parts should be reordered
            var elements = converter.Parse(@"
<table>
<tbody>
    <tr><td>Body</td></tr>
</tbody>
<thead>
    <tr><td>Header</td></tr>
</thead>
<tfoot>
    <tr><td>Footer</td></tr>
</tfoot>
</table>");

            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0], Is.TypeOf(typeof(Table)));

            var rows = elements[0].Elements<TableRow>();
            Assert.That(rows.Count(), Is.EqualTo(3));
            Assert.That(rows.ElementAt(0).InnerText, Is.EqualTo("Header"));
            Assert.That(rows.ElementAt(1).InnerText, Is.EqualTo("Body"));
            Assert.That(rows.ElementAt(2).InnerText, Is.EqualTo("Footer"));
        }

        [Test]
        public void ParseNotTag ()
        {
            var elements = converter.Parse(" < b >bold</b>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());

            elements = converter.Parse(" <3");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());
        }

        [Test]
        public void ParseNewlineFlow ()
        {
            // the new line should generate a space between "bold" and "text"
            var elements = converter.Parse(" <span>This is a <b>bold\n</b>text</span>");
        }


        [HttpPost]
        public async Task<IActionResult> GenerateDocument([FromBody] InsuranceDocumentDetails documentDetails)
        {
            try
            {

                //string filePath = Environment.CurrentDirectory + @"\\Documents\\" + documentDetails[0].clientDetails.FamilyName.ToString().Trim() + "," + documentDetails[0].clientDetails.ClientName.ToString().Trim() + "-" + documentDetails[0].clientDetails.ClientId.ToString().Trim() + ".docx";
                MemoryStream ms = new MemoryStream();
                string _storageConnection = Configuration.GetConnectionString("StorageConnectionString");
                CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(_storageConnection);
                CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
                CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("plstorage");

                if (await cloudBlobContainer.CreateIfNotExistsAsync())
                {
                    await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions
                    {
                        PublicAccess = BlobContainerPublicAccessType.Blob
                    });
                }
                string filePath = documentDetails.clientDetails.FamilyName.ToString().Trim() + "," + documentDetails.clientDetails.ClientName.ToString().Trim() + "-" + documentDetails.clientDetails.ClientId.ToString().Trim() + "-Insurance.docx";

                CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(filePath);
                using (WordprocessingDocument package = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document))
                {

                    MainDocumentPart mainPart = package.AddMainDocumentPart();
                    mainPart.Document = new Document();
                    Body body = mainPart.Document.AppendChild(new Body());
                    SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "008818E9", RsidR = "00543A0D" };
                    FooterReference footerReference1 = new FooterReference() { Type = HeaderFooterValues.Default, Id = "rId8" };

                    sectionProperties1.Append(footerReference1);

                    body.Append(sectionProperties1);





                    NumberingDefinitionsPart numberinfPart = mainPart.AddNewPart<NumberingDefinitionsPart>("numbering");
                    Numbering element = new Numbering(new AbstractNum(new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "•" }, new LevelJustification { Val = LevelJustificationValues.Left }, new ParagraphProperties(new Indentation { Left = "720", Hanging = "360" })) { LevelIndex = 0 }) { AbstractNumberId = 0 }, new NumberingInstance(new AbstractNumId() { Val = 0 }) { NumberID = 1 });
                    element.Save(numberinfPart);

                    Color orange = new Color() { Val = "ED7D27" };

                    //Your Risk Protection

                    var clientCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Client");
                    var partnerCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Partner");

                    if (clientCurrentInsurance.Count() > 0 || partnerCurrentInsurance.Count() > 0)
                    {
                        if (clientCurrentInsurance.Count() > 0)
                        {
                                  AddRiskProtection(body, documentDetails.clientDetails, clientCurrentInsurance, orange, 0);
                        }

                        if (partnerCurrentInsurance.Count() > 0)
                        {
                                     AddRiskProtection(body, documentDetails.clientDetails, partnerCurrentInsurance, orange, 1);
                        }
                    }

                    Paragraph break2 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break2);

                    //Paragraph pr0 = new Paragraph();
                    //add(pr0);
                    //body.Append(pr0);

                       GenerateBody(body);
                    Run br1 = new Run(new Break());
                    Paragraph pr1 = new Paragraph();
                    pr1.Append(new OpenXmlElement[] { br1 });
                    body.Append(pr1);

                       AddPara1(body);
                    //Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    //pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);
                        AddPara2(body);

                    //Your Insurance Needs

                    Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break3);

                    var clientNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Client");
                    var partnerNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Partner");

                    if (clientNeedsAnalysis.Count() > 0 || partnerNeedsAnalysis.Count() > 0)
                    {
                        Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Your Insurance Needs")));
                        body.Append(InsuranceNeeds);


                        if (clientNeedsAnalysis.Count() > 0)
                        {
                                AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                        }

                        if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                        {
                                  AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                        }

                    }


                    //Recommended Insurance
                    body.AppendChild(break3.CloneNode(true));
                    var clientProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Client");
                    var partnerProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Partner");

                    if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    {
                        if (clientProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, clientProposedInsurance, orange, 0);
                        }

                        if (partnerProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, partnerProposedInsurance, orange, 1);
                        }


                              AddStandardText(body, orange);
                    }

                    //Insurance ROP

                         AddReplacementOfProduct(body, documentDetails.currentInsurance, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break4);


                        AddImplementation(body, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    //Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    //body.Append(break4);


                    //if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    //{
                    //    Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Insurance replacement of product")));
                    //    body.Append(InsuranceNeeds);


                    //    if (clientNeedsAnalysis.Count() > 0)
                    //    {
                    //        AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                    //    }

                    //    if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                    //    {
                    //        AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                    //    }

                    //}

                    //Footer
                    var t = mainPart.Document.Body.Descendants<Table>().ToList();
                    var p = mainPart.Document.Body.Descendants<Paragraph>().ToList();
                    AlterTableType(t, p, package);

                    FooterPart footerPart = mainPart.AddNewPart<FooterPart>();

                    string footerPartId = mainPart.GetIdOfPart(footerPart);
                        GeneratePartContent(footerPart);

                    IEnumerable<SectionProperties> sections = mainPart.Document.Body.Elements<SectionProperties>();
                    foreach (var section in sections)
                    {
                        section.RemoveAllChildren<FooterReference>();
                        section.PrependChild<FooterReference>(new FooterReference() { Id = footerPartId });
                    }


                    package.MainDocumentPart.Document.Save();
                    package.Close();

                }


                ms.Position = 0;
                await blockBlob.UploadFromStreamAsync(ms);


                return File(ms.ToArray(), "application/octet-stream", "test");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void AddImplementation(Body body, ProposedInsuranceViewModel[] proposedInsurance, BasicDetails clientDetails, Color orange)
        {

            var implementation = new List<ProposedInsuranceViewModel>();
            var ongoing = new List<ProposedInsuranceViewModel>();

            foreach (ProposedInsuranceViewModel pI in proposedInsurance)
            {
                if (pI.Implementation.Commission > 0)
                {
                    implementation.Add(pI);
                }
                if (pI.Ongoing.Commission > 0)
                {
                    ongoing.Add(pI);
                }
            }

            if (implementation.Count() > 0 || ongoing.Count() > 0)
            {

                if (implementation.Any())
                {

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Implementation"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("If you wish to proceed with our advice, the following table shows the costs that apply to implement our recommendations."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in implementation)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }

                if (ongoing.Any())
                {

                    Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Ongoing advice"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The following table shows the ongoing costs. All fees are shown as annual amounts."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in ongoing)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }
            }


        }

        private void AddStandardText(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            r1.AppendChild(new Text("Other important information"));

            Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The recommended insurance cover may have exclusions applied, be loaded (higher premiums) or be declined depending on the outcome of underwriting."))));
            Paragraph p2 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("A death benefit will not be paid in the first 13 months of your life policy in the event of death by suicide."))));
            Paragraph p3 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Your policy has a cooling off period which allows you to cancel your cover and receive a refund of premiums paid. Please refer to the PDS for details."))));


            Paragraph s2 = body.AppendChild(new Paragraph());
            Run r2 = s2.AppendChild(new Run());
            RunProperties runProperties2 = r2.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties2.AppendChild(orange.CloneNode(true));
            r2.AppendChild(new Text("Your duty of disclosure"));

            Paragraph p5 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Before you apply for, extend, renew, vary or reinstate your insurance, it is important that you understand your duty of disclosure. The key elements are:"))));

            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You have a duty under law to disclose to the insurer every matter you know or could reasonably be expected to know that is relevant to their decision to accept your insurance application."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You must provide all the information requested by the insurer. Your duty could also extend beyond the questions in the insurance application form."))));
            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Your duty continues until the insurance application is accepted. You will need to disclose any relevant changes in your circumstances that occur before the insurance policy is issued."))));
            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("If you do not comply with your duty of disclosure, in some circumstances, your insurance may be avoided or varied, or future claims may be affected or denied. "))));

            Paragraph p6 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please refer to the relevant PDS for full details about your duty of disclosure."))));

            //Paragraph br = body.AppendChild(new Paragraph(new Run(new Break())));

            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Product Disclosure Statement of retained policies"));

            Color red = new Color() { Val = "FF0000" };

            Paragraph p7 = new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please read the following Product Disclosure Statement (PDS) for further information on your retained insurance ")));
            p7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " [policy/ies:] ", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(p7);

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[PDS name here]"))));

        }

        private void AddStandardTextROP(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            Color red = new Color() { Val = "FF0000" };
            r1.AppendChild(new Text("Product replacement recommendations"));


            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Based on our research and your needs and objectives, our recommendation is to replace your current insurance product."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Recommended product]"))));
            commentary1.Append(new Run(new RunProperties(), new Text { Text = " was deemed appropriate for you because: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If superior features]"))));
            commentary2.Append(new Run(new RunProperties(), new Text { Text = " It provides you with additional features. ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If lower premiums]"))));
            commentary3.Append(new Run(new RunProperties(), new Text { Text = " You will benefit from lower premiums. ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph commentary6 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("In making this recommendation, we compared "))));
            commentary6.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " recommended product ", Space = SpaceProcessingModeValues.Preserve }));
            commentary6.Append(new Run(new RunProperties(), new Text { Text = "to the following other products in the market: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary7 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 1]"))));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = " could ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[save you $XXX in annual costs and you would benefit from XXX features.]  ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = "However we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[you specifically stated you wanted the XXX product.] ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary8 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 2]"))));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = " offers ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[XXX features which could benefit you]", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = ", however we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[the annual costs are around $XXX more than XXX recommended product and this is more than you want to pay.] ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            // runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Important note:"));

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You should maintain your existing cover until the new policy is established, and all waiting periods are served, to ensure you have continuous cover. This could mean you are paying multiple premiums for a period of time. Once your new policy is in place and all waiting periods have been satisfied, the old policy can be cancelled."))));
            Paragraph commentary5 = new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("A policy that has been in force for three years or longer may have a greater level of protection against avoidance by an insurer if the duty of disclosure is breached or innocent misrepresentation occurs.")));
            commentary5.Append(new Run(new RunProperties(new Bold()), new Text { Text = " Cancelling your existing cover to take out new cover will restart this three year period where the insurer could avoid your policy if innocent non-disclosure or misrepresentation occurs.", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(commentary5);
        }

        private void AddRecommendedInsurance(Body body, BasicDetails clientDetails, IEnumerable<ProposedInsuranceViewModel> clientProposedInsurance, Color orange, int v)
        {
            Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));

            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));

            if (v == 0)
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.ClientName));
            }
            else
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.PartnerName));
            }


            foreach (ProposedInsuranceViewModel proposed in clientProposedInsurance)
            //New Table
            {
                Table table = body.AppendChild(new Table());
                TableProperties tableProp = new TableProperties();
                TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                tableProp.Append(tableStyle, tableWidth);
                table.AppendChild(tableProp);


                ////Header
                TableRow header = new TableRow();
                TableCell h1 = new TableCell();

                TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                ParagraphProperties hppLeft = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppCenter = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppRight = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                hppCenter.AppendChild((Justification)centerJustify.CloneNode(true));

                Justification rightJustify = new Justification() { Val = JustificationValues.Right };
                hppRight.AppendChild((Justification)rightJustify.CloneNode(true));

                Justification leftJustify = new Justification() { Val = JustificationValues.Left };

                TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                hcp.Append(hcm1, hs1, hcb);
                //hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                h1.Append(hcp);

                h1.AppendChild((ParagraphProperties)hppLeft.CloneNode(true));

                var heading = "";
                if (proposed.ReplacementId == 0)
                {
                    heading = "Purchase";
                }
                else
                {
                    heading = "";
                }

                h1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(heading))));

                TableCell h2 = new TableCell();
                h2.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h2.Append((TableCellProperties)hcp.CloneNode(true));
                h2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Provider))));

                TableCell h3 = new TableCell();
                h3.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h3.Append((TableCellProperties)hcp.CloneNode(true));
                h3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                header.Append(h1, h2, h3);

                table.Append(header);
                //Body
                TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp2 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });

                pp2.AppendChild((Justification)rightJustify.CloneNode(true));
                pp.AppendChild((Justification)leftJustify.CloneNode(true));
                tcp.Append(tcbL, tcm);
                tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));


                if (proposed.LifeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Life")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.LifeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.LifeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));



                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.LifeCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.LifeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TpdCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("TPD")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TpdCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TpdCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TpdCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TraumaCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Trauma")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TraumaCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TraumaCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TraumaCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TraumaCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }


                    if (proposed.TraumaCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.IncomeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Income Protection")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.IncomeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.IncomeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().MonthlyBenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.IncomeCover.First().MonthlyBenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WaitingPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Waiting Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WaitingPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().BenefitPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().BenefitPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }


                Run linebreak = new Run(new Break());
                Paragraph productCost = new Paragraph();
                productCost.Append(new OpenXmlElement[] { (Run)linebreak.CloneNode(true), new Run(new RunProperties(new Bold()), new Text("Please note the following: ")) });
                body.Append(productCost);

            }
        }

        private void add(Paragraph body)
        {
            AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice() { Requires = "wps" };

            W.Drawing drawing1 = new W.Drawing();

            Wp.Anchor anchor1 = new Wp.Anchor() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)114935U, DistanceFromRight = (UInt32Value)114935U, SimplePos = false, RelativeHeight = (UInt32Value)251676672U, BehindDoc = true, Locked = false, LayoutInCell = true, AllowOverlap = true, EditId = "3A313D92", AnchorId = "5438FE6E" };
            Wp.SimplePosition simplePosition1 = new Wp.SimplePosition() { X = 0L, Y = 0L };

            Wp.HorizontalPosition horizontalPosition1 = new Wp.HorizontalPosition() { RelativeFrom = Wp.HorizontalRelativePositionValues.Column };
            Wp.PositionOffset positionOffset1 = new Wp.PositionOffset();
            positionOffset1.Text = "6030595";

            horizontalPosition1.Append(positionOffset1);

            Wp.VerticalPosition verticalPosition1 = new Wp.VerticalPosition() { RelativeFrom = Wp.VerticalRelativePositionValues.Paragraph };
            Wp.PositionOffset positionOffset2 = new Wp.PositionOffset();
            positionOffset2.Text = "97155";

            verticalPosition1.Append(positionOffset2);
            Wp.Extent extent1 = new Wp.Extent() { Cx = 35560L, Cy = 13970L };
            Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 8255L, TopEdge = 5715L, RightEdge = 3810L, BottomEdge = 8890L };
            Wp.WrapNone wrapNone1 = new Wp.WrapNone();
            Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = (UInt32Value)92U, Name = "Text Box 92" };

            Wp.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Wp.NonVisualGraphicFrameDrawingProperties();

            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks();
            graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            A.Graphic graphic1 = new A.Graphic();
            graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" };

            Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape();

            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties() { TextBox = true };
            A.ShapeLocks shapeLocks1 = new A.ShapeLocks() { NoChangeArrowheads = true };

            nonVisualDrawingShapeProperties1.Append(shapeLocks1);

            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto };

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
            A.Extents extents1 = new A.Extents() { Cx = 35560L, Cy = 13970L };

            transform2D1.Append(offset1);
            transform2D1.Append(extents1);

            A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "FFFFFF" };
            A.Alpha alpha1 = new A.Alpha() { Val = 0 };

            rgbColorModelHex1.Append(alpha1);

            solidFill1.Append(rgbColorModelHex1);

            A.Outline outline1 = new A.Outline();
            A.NoFill noFill1 = new A.NoFill();

            outline1.Append(noFill1);

            A.ShapePropertiesExtensionList shapePropertiesExtensionList1 = new A.ShapePropertiesExtensionList();

            A.ShapePropertiesExtension shapePropertiesExtension1 = new A.ShapePropertiesExtension() { Uri = "{91240B29-F687-4F45-9708-019B960494DF}" };

            A14.HiddenLineProperties hiddenLineProperties1 = new A14.HiddenLineProperties() { Width = 9525 };
            hiddenLineProperties1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");

            A.SolidFill solidFill2 = new A.SolidFill();
            A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = "000000" };

            solidFill2.Append(rgbColorModelHex2);
            A.Miter miter1 = new A.Miter() { Limit = 800000 };
            A.HeadEnd headEnd1 = new A.HeadEnd();
            A.TailEnd tailEnd1 = new A.TailEnd();

            hiddenLineProperties1.Append(solidFill2);
            hiddenLineProperties1.Append(miter1);
            hiddenLineProperties1.Append(headEnd1);
            hiddenLineProperties1.Append(tailEnd1);

            shapePropertiesExtension1.Append(hiddenLineProperties1);

            shapePropertiesExtensionList1.Append(shapePropertiesExtension1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(presetGeometry1);
            shapeProperties1.Append(solidFill1);
            shapeProperties1.Append(outline1);
            shapeProperties1.Append(shapePropertiesExtensionList1);

            Wps.TextBoxInfo2 textBoxInfo21 = new Wps.TextBoxInfo2();

            W.TextBoxContent textBoxContent1 = new W.TextBoxContent();

            W.Paragraph paragraph1 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "04CE03A0", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties1 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId1 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties1 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts1 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold1 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript1 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(paragraphStyleId1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            W.Run run1 = new W.Run();

            W.RunProperties runProperties1 = new W.RunProperties();
            W.RunFonts runFonts2 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold2 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript2 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSizeComplexScript2);
            W.Text text1 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text1.Text = " ";

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            W.Paragraph paragraph2 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "6E6DB8AF", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties2 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId2 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties2 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts3 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold3 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript3 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties2.Append(runFonts3);
            paragraphMarkRunProperties2.Append(bold3);
            paragraphMarkRunProperties2.Append(fontSizeComplexScript3);

            paragraphProperties2.Append(paragraphStyleId2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            W.Run run2 = new W.Run();

            W.RunProperties runProperties2 = new W.RunProperties();
            W.RunFonts runFonts4 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold4 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript4 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(bold4);
            runProperties2.Append(fontSizeComplexScript4);
            W.Text text2 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text2.Text = " ";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);

            W.Paragraph paragraph3 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "02530E2F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties3 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId3 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties3 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts5 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold5 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript5 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties3.Append(runFonts5);
            paragraphMarkRunProperties3.Append(bold5);
            paragraphMarkRunProperties3.Append(fontSizeComplexScript5);

            paragraphProperties3.Append(paragraphStyleId3);
            paragraphProperties3.Append(paragraphMarkRunProperties3);

            W.Run run3 = new W.Run();

            W.RunProperties runProperties3 = new W.RunProperties();
            W.RunFonts runFonts6 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold6 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript6 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties3.Append(runFonts6);
            runProperties3.Append(bold6);
            runProperties3.Append(fontSizeComplexScript6);
            W.Text text3 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text3.Text = " ";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run3);

            W.Paragraph paragraph4 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4753D73F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties4 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId4 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties4 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts7 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold7 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript7 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties4.Append(runFonts7);
            paragraphMarkRunProperties4.Append(bold7);
            paragraphMarkRunProperties4.Append(fontSizeComplexScript7);

            paragraphProperties4.Append(paragraphStyleId4);
            paragraphProperties4.Append(paragraphMarkRunProperties4);

            paragraph4.Append(paragraphProperties4);

            W.Paragraph paragraph5 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7675723D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties5 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId5 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties5 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts8 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold8 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript8 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties5.Append(runFonts8);
            paragraphMarkRunProperties5.Append(bold8);
            paragraphMarkRunProperties5.Append(fontSizeComplexScript8);

            paragraphProperties5.Append(paragraphStyleId5);
            paragraphProperties5.Append(paragraphMarkRunProperties5);

            W.Run run4 = new W.Run();

            W.RunProperties runProperties4 = new W.RunProperties();
            W.RunFonts runFonts9 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold9 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript9 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties4.Append(runFonts9);
            runProperties4.Append(bold9);
            runProperties4.Append(fontSizeComplexScript9);
            W.Text text4 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text4.Text = " ";

            run4.Append(runProperties4);
            run4.Append(text4);

            paragraph5.Append(paragraphProperties5);
            paragraph5.Append(run4);

            W.Paragraph paragraph6 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "12AC83A7", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties6 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId6 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties6 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts10 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold10 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript10 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties6.Append(runFonts10);
            paragraphMarkRunProperties6.Append(bold10);
            paragraphMarkRunProperties6.Append(fontSizeComplexScript10);

            paragraphProperties6.Append(paragraphStyleId6);
            paragraphProperties6.Append(paragraphMarkRunProperties6);

            W.Run run5 = new W.Run();

            W.RunProperties runProperties5 = new W.RunProperties();
            W.RunFonts runFonts11 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold11 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript11 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties5.Append(runFonts11);
            runProperties5.Append(bold11);
            runProperties5.Append(fontSizeComplexScript11);
            W.Text text5 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text5.Text = " ";

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph6.Append(paragraphProperties6);
            paragraph6.Append(run5);

            W.Paragraph paragraph7 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7F4349F2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties7 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId7 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties7 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts12 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold12 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript12 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties7.Append(runFonts12);
            paragraphMarkRunProperties7.Append(bold12);
            paragraphMarkRunProperties7.Append(fontSizeComplexScript12);

            paragraphProperties7.Append(paragraphStyleId7);
            paragraphProperties7.Append(paragraphMarkRunProperties7);

            W.Run run6 = new W.Run();

            W.RunProperties runProperties6 = new W.RunProperties();
            W.RunFonts runFonts13 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold13 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript13 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties6.Append(runFonts13);
            runProperties6.Append(bold13);
            runProperties6.Append(fontSizeComplexScript13);
            W.Text text6 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text6.Text = " ";

            run6.Append(runProperties6);
            run6.Append(text6);

            paragraph7.Append(paragraphProperties7);
            paragraph7.Append(run6);

            W.Paragraph paragraph8 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5378D687", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties8 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId8 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties8 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts14 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold14 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript14 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties8.Append(runFonts14);
            paragraphMarkRunProperties8.Append(bold14);
            paragraphMarkRunProperties8.Append(fontSizeComplexScript14);

            paragraphProperties8.Append(paragraphStyleId8);
            paragraphProperties8.Append(paragraphMarkRunProperties8);

            W.Run run7 = new W.Run();

            W.RunProperties runProperties7 = new W.RunProperties();
            W.RunFonts runFonts15 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold15 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript15 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties7.Append(runFonts15);
            runProperties7.Append(bold15);
            runProperties7.Append(fontSizeComplexScript15);
            W.Text text7 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text7.Text = " ";

            run7.Append(runProperties7);
            run7.Append(text7);

            paragraph8.Append(paragraphProperties8);
            paragraph8.Append(run7);

            W.Paragraph paragraph9 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5DCADE92", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties9 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId9 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties9 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts16 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold16 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript16 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties9.Append(runFonts16);
            paragraphMarkRunProperties9.Append(bold16);
            paragraphMarkRunProperties9.Append(fontSizeComplexScript16);

            paragraphProperties9.Append(paragraphStyleId9);
            paragraphProperties9.Append(paragraphMarkRunProperties9);

            W.Run run8 = new W.Run();

            W.RunProperties runProperties8 = new W.RunProperties();
            W.RunFonts runFonts17 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold17 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript17 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties8.Append(runFonts17);
            runProperties8.Append(bold17);
            runProperties8.Append(fontSizeComplexScript17);
            W.Text text8 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text8.Text = " ";

            run8.Append(runProperties8);
            run8.Append(text8);

            paragraph9.Append(paragraphProperties9);
            paragraph9.Append(run8);

            W.Paragraph paragraph10 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4AC96599", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties10 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId10 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties10 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts18 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold18 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript18 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties10.Append(runFonts18);
            paragraphMarkRunProperties10.Append(bold18);
            paragraphMarkRunProperties10.Append(fontSizeComplexScript18);

            paragraphProperties10.Append(paragraphStyleId10);
            paragraphProperties10.Append(paragraphMarkRunProperties10);

            W.Run run9 = new W.Run();

            W.RunProperties runProperties9 = new W.RunProperties();
            W.RunFonts runFonts19 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold19 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript19 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties9.Append(runFonts19);
            runProperties9.Append(bold19);
            runProperties9.Append(fontSizeComplexScript19);
            W.Text text9 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text9.Text = " ";

            run9.Append(runProperties9);
            run9.Append(text9);

            paragraph10.Append(paragraphProperties10);
            paragraph10.Append(run9);

            W.Paragraph paragraph11 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "2B4B8144", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties11 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId11 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties11 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts20 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold20 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript20 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties11.Append(runFonts20);
            paragraphMarkRunProperties11.Append(bold20);
            paragraphMarkRunProperties11.Append(fontSizeComplexScript20);

            paragraphProperties11.Append(paragraphStyleId11);
            paragraphProperties11.Append(paragraphMarkRunProperties11);

            W.Run run10 = new W.Run();

            W.RunProperties runProperties10 = new W.RunProperties();
            W.RunFonts runFonts21 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold21 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript21 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties10.Append(runFonts21);
            runProperties10.Append(bold21);
            runProperties10.Append(fontSizeComplexScript21);
            W.Text text10 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text10.Text = " ";

            run10.Append(runProperties10);
            run10.Append(text10);

            paragraph11.Append(paragraphProperties11);
            paragraph11.Append(run10);

            W.Paragraph paragraph12 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "0AAAC9A6", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties12 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId12 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties12 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts22 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold22 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript22 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties12.Append(runFonts22);
            paragraphMarkRunProperties12.Append(bold22);
            paragraphMarkRunProperties12.Append(fontSizeComplexScript22);

            paragraphProperties12.Append(paragraphStyleId12);
            paragraphProperties12.Append(paragraphMarkRunProperties12);

            W.Run run11 = new W.Run();

            W.RunProperties runProperties11 = new W.RunProperties();
            W.RunFonts runFonts23 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold23 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript23 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties11.Append(runFonts23);
            runProperties11.Append(bold23);
            runProperties11.Append(fontSizeComplexScript23);
            W.Text text11 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text11.Text = " ";

            run11.Append(runProperties11);
            run11.Append(text11);

            paragraph12.Append(paragraphProperties12);
            paragraph12.Append(run11);

            W.Paragraph paragraph13 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5506A4C5", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties13 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId13 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties13 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts24 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold24 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript24 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties13.Append(runFonts24);
            paragraphMarkRunProperties13.Append(bold24);
            paragraphMarkRunProperties13.Append(fontSizeComplexScript24);

            paragraphProperties13.Append(paragraphStyleId13);
            paragraphProperties13.Append(paragraphMarkRunProperties13);

            W.Run run12 = new W.Run();

            W.RunProperties runProperties12 = new W.RunProperties();
            W.RunFonts runFonts25 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold25 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript25 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties12.Append(runFonts25);
            runProperties12.Append(bold25);
            runProperties12.Append(fontSizeComplexScript25);
            W.Text text12 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text12.Text = " ";

            run12.Append(runProperties12);
            run12.Append(text12);

            paragraph13.Append(paragraphProperties13);
            paragraph13.Append(run12);

            W.Paragraph paragraph14 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7AEBEDA2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties14 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId14 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties14 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts26 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold26 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript26 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties14.Append(runFonts26);
            paragraphMarkRunProperties14.Append(bold26);
            paragraphMarkRunProperties14.Append(fontSizeComplexScript26);

            paragraphProperties14.Append(paragraphStyleId14);
            paragraphProperties14.Append(paragraphMarkRunProperties14);

            W.Run run13 = new W.Run();

            W.RunProperties runProperties13 = new W.RunProperties();
            W.RunFonts runFonts27 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold27 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript27 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties13.Append(runFonts27);
            runProperties13.Append(bold27);
            runProperties13.Append(fontSizeComplexScript27);
            W.Text text13 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text13.Text = " ";

            run13.Append(runProperties13);
            run13.Append(text13);

            paragraph14.Append(paragraphProperties14);
            paragraph14.Append(run13);

            W.Paragraph paragraph15 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "48085869", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties15 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId15 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties15 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts28 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold28 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript28 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties15.Append(runFonts28);
            paragraphMarkRunProperties15.Append(bold28);
            paragraphMarkRunProperties15.Append(fontSizeComplexScript28);

            paragraphProperties15.Append(paragraphStyleId15);
            paragraphProperties15.Append(paragraphMarkRunProperties15);

            paragraph15.Append(paragraphProperties15);

            W.Paragraph paragraph16 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "03349807", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties16 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId16 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties16 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts29 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold29 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript29 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties16.Append(runFonts29);
            paragraphMarkRunProperties16.Append(bold29);
            paragraphMarkRunProperties16.Append(fontSizeComplexScript29);

            paragraphProperties16.Append(paragraphStyleId16);
            paragraphProperties16.Append(paragraphMarkRunProperties16);

            W.Run run14 = new W.Run();

            W.RunProperties runProperties14 = new W.RunProperties();
            W.RunFonts runFonts30 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold30 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript30 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties14.Append(runFonts30);
            runProperties14.Append(bold30);
            runProperties14.Append(fontSizeComplexScript30);
            W.Text text14 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text14.Text = " ";

            run14.Append(runProperties14);
            run14.Append(text14);

            paragraph16.Append(paragraphProperties16);
            paragraph16.Append(run14);

            W.Paragraph paragraph17 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "13B8FCE4", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties17 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId17 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties17 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts31 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold31 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript31 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties17.Append(runFonts31);
            paragraphMarkRunProperties17.Append(bold31);
            paragraphMarkRunProperties17.Append(fontSizeComplexScript31);

            paragraphProperties17.Append(paragraphStyleId17);
            paragraphProperties17.Append(paragraphMarkRunProperties17);

            paragraph17.Append(paragraphProperties17);

            W.Paragraph paragraph18 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3ACA8116", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties18 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId18 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties18 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts32 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold32 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript32 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties18.Append(runFonts32);
            paragraphMarkRunProperties18.Append(bold32);
            paragraphMarkRunProperties18.Append(fontSizeComplexScript32);

            paragraphProperties18.Append(paragraphStyleId18);
            paragraphProperties18.Append(paragraphMarkRunProperties18);

            W.Run run15 = new W.Run();

            W.RunProperties runProperties15 = new W.RunProperties();
            W.RunFonts runFonts33 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold33 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript33 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties15.Append(runFonts33);
            runProperties15.Append(bold33);
            runProperties15.Append(fontSizeComplexScript33);
            W.Text text15 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text15.Text = " ";

            run15.Append(runProperties15);
            run15.Append(text15);

            paragraph18.Append(paragraphProperties18);
            paragraph18.Append(run15);

            W.Paragraph paragraph19 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "05C6F3B3", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties19 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId19 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties19 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts34 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold34 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript34 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties19.Append(runFonts34);
            paragraphMarkRunProperties19.Append(bold34);
            paragraphMarkRunProperties19.Append(fontSizeComplexScript34);

            paragraphProperties19.Append(paragraphStyleId19);
            paragraphProperties19.Append(paragraphMarkRunProperties19);

            W.Run run16 = new W.Run();

            W.RunProperties runProperties16 = new W.RunProperties();
            W.RunFonts runFonts35 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold35 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript35 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties16.Append(runFonts35);
            runProperties16.Append(bold35);
            runProperties16.Append(fontSizeComplexScript35);
            W.Text text16 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text16.Text = " ";

            run16.Append(runProperties16);
            run16.Append(text16);

            paragraph19.Append(paragraphProperties19);
            paragraph19.Append(run16);

            W.Paragraph paragraph20 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3C7FD12D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties20 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId20 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties20 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts36 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold36 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript36 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties20.Append(runFonts36);
            paragraphMarkRunProperties20.Append(bold36);
            paragraphMarkRunProperties20.Append(fontSizeComplexScript36);

            paragraphProperties20.Append(paragraphStyleId20);
            paragraphProperties20.Append(paragraphMarkRunProperties20);

            paragraph20.Append(paragraphProperties20);

            textBoxContent1.Append(paragraph1);
            textBoxContent1.Append(paragraph2);
            textBoxContent1.Append(paragraph3);
            textBoxContent1.Append(paragraph4);
            textBoxContent1.Append(paragraph5);
            textBoxContent1.Append(paragraph6);
            textBoxContent1.Append(paragraph7);
            textBoxContent1.Append(paragraph8);
            textBoxContent1.Append(paragraph9);
            textBoxContent1.Append(paragraph10);
            textBoxContent1.Append(paragraph11);
            textBoxContent1.Append(paragraph12);
            textBoxContent1.Append(paragraph13);
            textBoxContent1.Append(paragraph14);
            textBoxContent1.Append(paragraph15);
            textBoxContent1.Append(paragraph16);
            textBoxContent1.Append(paragraph17);
            textBoxContent1.Append(paragraph18);
            textBoxContent1.Append(paragraph19);
            textBoxContent1.Append(paragraph20);

            textBoxInfo21.Append(textBoxContent1);

            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties() { Rotation = 0, Vertical = A.TextVerticalValues.Horizontal, Wrap = A.TextWrappingValues.Square, LeftInset = 0, TopInset = 0, RightInset = 0, BottomInset = 0, Anchor = A.TextAnchoringTypeValues.Top, AnchorCenter = false, UpRight = true };
            A.NoAutoFit noAutoFit1 = new A.NoAutoFit();

            textBodyProperties1.Append(noAutoFit1);

            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(textBoxInfo21);
            wordprocessingShape1.Append(textBodyProperties1);

            graphicData1.Append(wordprocessingShape1);

            graphic1.Append(graphicData1);

            Wp14.RelativeWidth relativeWidth1 = new Wp14.RelativeWidth() { ObjectId = Wp14.SizeRelativeHorizontallyValues.Page };
            Wp14.PercentageWidth percentageWidth1 = new Wp14.PercentageWidth();
            percentageWidth1.Text = "0";

            relativeWidth1.Append(percentageWidth1);

            Wp14.RelativeHeight relativeHeight1 = new Wp14.RelativeHeight() { RelativeFrom = Wp14.SizeRelativeVerticallyValues.Page };
            Wp14.PercentageHeight percentageHeight1 = new Wp14.PercentageHeight();
            percentageHeight1.Text = "0";

            relativeHeight1.Append(percentageHeight1);

            anchor1.Append(simplePosition1);
            anchor1.Append(horizontalPosition1);
            anchor1.Append(verticalPosition1);
            anchor1.Append(extent1);
            anchor1.Append(effectExtent1);
            anchor1.Append(wrapNone1);
            anchor1.Append(docProperties1);
            anchor1.Append(nonVisualGraphicFrameDrawingProperties1);
            anchor1.Append(graphic1);
            anchor1.Append(relativeWidth1);
            anchor1.Append(relativeHeight1);

            drawing1.Append(anchor1);

            //alternateContentChoice1.Append(drawing1);
            //body.Append(alternateContentChoice1);
            //body.Append(drawing1);
            Run run = new Run();
            run.AppendChild(drawing1);

            body.Append(run);

        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }

        [GenericTestCase(typeof(Bold), @"<b>Bold</b>")]
        [GenericTestCase(typeof(Bold), @"<strong>Strong</strong>")]
        [GenericTestCase(typeof(Italic), @"<i>Italic</i>")]
        [GenericTestCase(typeof(Italic), @"<em>Italic</em>")]
        [GenericTestCase(typeof(Strike), @"<s>Strike</s>")]
        [GenericTestCase(typeof(Strike), @"<strike>Strike</strike>")]
        [GenericTestCase(typeof(Strike), @"<del>Del</del>")]
        [GenericTestCase(typeof(Underline), @"<u>Underline</u>")]
        [GenericTestCase(typeof(Underline), @"<ins>Inserted</ins>")]
        public void ParseHtmlElements<T> (string html) where T : OpenXmlElement
        {
            ParsePhrasing<T>(html);
        }

        [TestCase(@"<sub>Subscript</sub>", VerticalPositionValues.Subscript)]
        [TestCase(@"<sup>Superscript</sup>", VerticalPositionValues.Superscript)]
        public void ParseSubSup (string html, VerticalPositionValues val)
        {
            var textAlign = ParsePhrasing<VerticalTextAlignment>(html);
            Assert.That(textAlign.Val.HasValue, Is.EqualTo(true));
            Assert.That(textAlign.Val.Value, Is.EqualTo(val));
        }

        [Test]
        public void ParseStyle ()
        {
            var elements = converter.Parse(@"<b style=""
font-style:italic;
font-size:12px;
color:red;
text-decoration:underline;
"">bold with italic style</b>");
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.Multiple(() => {
                Assert.IsTrue(runProperties.HasChild<Bold>());
                Assert.IsTrue(runProperties.HasChild<Italic>());
                Assert.IsTrue(runProperties.HasChild<FontSize>());
                Assert.IsTrue(runProperties.HasChild<Underline>());
                Assert.IsTrue(runProperties.HasChild<Color>());
            });
        }

        /*[Test]
        public void ParseDisruptiveStyle ()
        {
            //TODO:
            // italic should not be applied as we specify font-style=normal
            var elements = converter.Parse("<i style='font-style:normal'>Not italics</i>");
            Assert.Multiple(() => {
                var runProperties = elements[0].FirstChild.GetFirstChild<RunProperties>();
                Assert.IsNotNull(runProperties);
                Assert.IsTrue(!runProperties.HasChild<Italic>());
            });

            elements = converter.Parse("<span style='font-style:italic'><i style='font-style:normal'>Not italics</i></span>");
        }*/

        [TestCase(@"<q>Build a future where people live in harmony with nature.</q>", true)]
        [TestCase(@"<cite>Build a future where people live in harmony with nature.</cite>", false)]
        public void ParseQuote(string html, bool hasQuote)
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);
            if (hasQuote)
            {
                Assert.That(run.InnerText, Is.EqualTo(" " + converter.HtmlStyles.QuoteCharacters.Prefix));

                Run lastRun = elements[0].GetLastChild<Run>();
                Assert.IsNotNull(run);
                Assert.That(lastRun.InnerText, Is.EqualTo(converter.HtmlStyles.QuoteCharacters.Suffix));

                // focus the content run
                run = (Run) run.NextSibling();
            }

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var runStyle = runProperties.GetFirstChild<RunStyle>();
            Assert.IsNotNull(runStyle);
            Assert.That(runStyle.Val.Value, Is.EqualTo("QuoteChar"));
        }

        [Test]
        public void ParseBreak()
        {
            var elements = converter.Parse(@"Lorem<br/>Ipsum");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            Assert.That(elements[0].ChildElements[0], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[1], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[2], Is.InstanceOf(typeof(Run)));
            Assert.IsNotNull(((Run)elements[0].ChildElements[1]).GetFirstChild<Break>());
        }

        private T ParsePhrasing<T> (string html) where T : OpenXmlElement
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var tag = runProperties.GetFirstChild<T>();
            Assert.IsNotNull(tag);
            return tag;
        }


        private void Initialize(string MajorFont, string MinorFont, List<System.Drawing.Color> ThemeColors, List<System.Drawing.Color> IndexedColors)
        {
            this.MajorFont = MajorFont;
            this.MinorFont = MinorFont;

            int i;
            this.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < ThemeColors.Count; ++i)
            {
                this.listThemeColors.Add(ThemeColors[i]);
            }

            this.listIndexedColors = new List<System.Drawing.Color>();
            for (i = 0; i < IndexedColors.Count; ++i)
            {
                this.listIndexedColors.Add(IndexedColors[i]);
            }

            istrReal = new InlineString();
        }

        /// <summary>
        /// Set the text. If text formatting is needed, use one of the AppendText() functions.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void SetText(string Text)
        {
            if (Text == null || Text.Length == 0)
            {
                this.istrReal.Text = null;
            }
            else
            {
                this.istrReal.Text = new Text();
                this.istrReal.Text.Text = Text;
                if (SLTool.ToPreserveSpace(Text))
                {
                    this.istrReal.Text.Space = SpaceProcessingModeValues.Preserve;
                }
            }
        }

        /// <summary>
        /// Get the text. This is the plain text string, and not the rich text runs.
        /// </summary>
        /// <returns>The plain text.</returns>
        public string GetText()
        {
            string result = string.Empty;
            if (this.istrReal.Text != null) result = this.istrReal.Text.Text;

            return result;
        }

        /// <summary>
        /// Get a list of rich text runs.
        /// </summary>
        /// <returns>A list of rich text runs.</returns>
        public List<SLRun> GetRuns()
        {
            List<SLRun> result = new List<SLRun>();
            SLRun r;

            using (OpenXmlReader oxr = OpenXmlReader.Create(this.istrReal))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Run))
                    {
                        r = new SLRun();
                        r.FromRun((Run)oxr.LoadCurrentElement());
                        result.Add(r.Clone());
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Replace the internal list of rich text runs.
        /// </summary>
        /// <param name="Runs">The new list of rich text runs for replacing.</param>
        public void ReplaceRuns(List<SLRun> Runs)
        {
            string sText = string.Empty;
            if (this.istrReal.Text != null) sText = this.istrReal.Text.Text;

            this.istrReal.RemoveAllChildren<Text>();
            this.istrReal.RemoveAllChildren<Run>();

            int i;
            // start from the end because we're prepending to the front
            for (i = Runs.Count - 1; i >= 0; --i)
            {
                this.istrReal.PrependChild<Run>(Runs[i].ToRun());
            }

            this.SetText(sText);
        }

        /// <summary>
        /// Append given text in the current theme's minor font and default font size.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void AppendText(string Text)
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);
            font.SetFont(FontSchemeValues.Minor, SLConstants.DefaultFontSize);

            this.AppendText(Text, font);
        }


        public Run GetRun(RunProperties runProperties)
        {
            var run = new Run {RunProperties = runProperties.CloneNode()};

            if (_config.Bold.HasValue)
            {
                run.RunProperties.Bold = new Bold {Val = OnOffValue.FromBoolean(_config.Bold.Value)};
            }

            if (_config.Italic.HasValue)
            {
                run.RunProperties.Italic = new Italic {Val = OnOffValue.FromBoolean(_config.Italic.Value)};
            }

            if (_config.Underline.HasValue)
            {
                run.RunProperties.Underline = new Underline {Val = _config.Underline};
            }

            if (_config.FontSize != null)
            {
                run.RunProperties.FontSize = new FontSize{Val = _config.FontSize};
            }

            if (!string.IsNullOrEmpty(this))
            {
                var lines = ((string) this).Split(new[] {"\r\n", "\n"}, StringSplitOptions.None).AsIndexed();

                foreach (var line in lines)
                {
                    if (!line.IsFirst)
                    {
                        run.AppendChild(new Break());
                    }

                    if (!string.IsNullOrEmpty(line.Value))
                    {
                        run.AppendChild(new Text(line) {Space = SpaceProcessingModeValues.Preserve});
                    }
                }
            }

            if (_config.Value == null)
            {
                run.AppendChild(new Break());
            }

            return run;
        }

        public static void AddTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            if (genegalRules.FontStyle != null)
                runProperties.AddFontStyle(genegalRules.FontStyle);

            if (genegalRules.FontSize != 0)
                runProperties.AddFontSize(genegalRules.FontSize);

            if (genegalRules.Font != null)
                runProperties.AddFont(genegalRules.Font);
        }

        public static void AddFootNoteTextProperties(this RunProperties runProperties, IGenegalRules genegalRules)
        {
            //if (genegalRules.FootNote.FontStyle != null)
            //    runProperties.AddFontStyle(genegalRules.FootNote.FontStyle);
            if (genegalRules.FootNote != null)
            {
                if (genegalRules.FootNote.Style != null)
                    runProperties.AddFont(genegalRules.FootNote.Style);
                if (genegalRules.FootNote.Size != 0)
                    runProperties.AddFontSize(genegalRules.FootNote.Size);
            }
        }

        private static void AddFontStyle(this RunProperties runProperties, OnOffType type)
        {
            if (type is Italic)
            {
                runProperties.Italic = new Italic();
            } 
            if (type is Bold)
            {
                runProperties.Bold = new Bold();
            }
        }

        /// <summary>
        /// Размер шрифта будет в два раза меньше
        /// </summary>
        private static void AddFontSize(this RunProperties runProperties, float size)
        {
            runProperties.AppendChild(new FontSize() { Val = size.ToString()});
        }

        private static void AddFont(this RunProperties runProperties, string font)
        {
            runProperties.AppendChild(new RunFonts() { Ascii = font });
        }

        static void Main(string[] args)
        {
            WordDocument doc = new WordDocument();

            Style style1 = new Style();
            style1.ID = "Heading 1";
            style1.Name = "Heading 1";
            style1.Type = StyleType.Paragraph;
            style1.Primary = ExtendedBoolean.True;
            style1.UserInterfacePriority = 9;

            style1.ParagraphProperties.KeepNext = ExtendedBoolean.True;
            style1.ParagraphProperties.KeepLines = ExtendedBoolean.True;
            style1.ParagraphProperties.OutlineLevel = 0;

            Spacing spacing1 = new Spacing();
            spacing1.After = 0;
            spacing1.Before = 480;

            style1.ParagraphProperties.Spacing = spacing1;

            style1.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style1.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style1.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style1.RunProperties.Bold = ExtendedBoolean.True;
            style1.RunProperties.ComplexScriptBold = ExtendedBoolean.True;
            style1.RunProperties.FontSize = 28; //14 points
            style1.RunProperties.ComplexScriptFontSize = 28; //14 points
           
            Style style2 = new Style();
            style2.ID = "Title";
            style2.Name = "Title";
            style2.Type = StyleType.Paragraph;
            style2.Primary = ExtendedBoolean.True;
            style2.UserInterfacePriority = 9;
           
            BottomBorder bottomBorder = new BottomBorder(StandardBorderStyle.SingleLine);
            bottomBorder.Space = 4;
            bottomBorder.Width = 8;

            style2.ParagraphProperties.BottomBorder = bottomBorder;
            style2.ParagraphProperties.IgnoreSpace = ExtendedBoolean.True;

            Spacing spacing2 = new Spacing();
            spacing2.After = 300;
            spacing2.Line = 240;
            spacing2.LineRule = LineSpacingRule.Auto;

            style2.ParagraphProperties.Spacing = spacing2;

            style2.RunProperties.Fonts.AsciiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.EastAsiaThemeFont = ThemeFont.MajorEastAsia;
            style2.RunProperties.Fonts.HighAnsiThemeFont = ThemeFont.MajorHighAnsi;
            style2.RunProperties.Fonts.ComplexScriptThemeFont = ThemeFont.MajorComplexScript;
            style2.RunProperties.Spacing = 5;
            style2.RunProperties.FontKern = 28;
            style2.RunProperties.FontSize = 52; //26 points
            style2.RunProperties.ComplexScriptFontSize = 52; //26 points

            StyleDefinitions documentStyles = new StyleDefinitions();
            documentStyles.Styles.Add(style1);
            documentStyles.Styles.Add(style2);

            doc.StyleDefinitions = documentStyles;

            Run run1 = new Run();
            run1.AddText("Text with style \"Heading 1\"");

            Run run2 = new Run();
            run2.AddText("Text with style \"Title\"");

            Paragraph paragraph1 = new Paragraph();
            paragraph1.StyleName = "Heading 1";
            paragraph1.Add(run1);

            Paragraph paragraph2 = new Paragraph();
            paragraph2.StyleName = "Title";
            paragraph2.Add(run2);

            Paragraph emptyParagraph = new Paragraph();

            doc.Body.Add(paragraph1);
            doc.Body.Add(emptyParagraph);
            doc.Body.Add(paragraph2);

            doc.Save("c:\\test\\output.docx", true);
        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }

DocumentFormat.OpenXml.Math.RunProperties : IEnumerable

Constructors :

public RunProperties()
public RunProperties(IEnumerable<OpenXmlElement> childElements = )
public RunProperties(OpenXmlElement[] childElements = )
public RunProperties(String outerXml = )

Methods :

public Literal get_Literal()
public Void set_Literal(Literal value = )
public OpenXmlElement CloneNode(Boolean deep = )
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasChildren()
public String get_InnerText()
public Void set_InnerXml(String value = )
public Boolean AddChild(OpenXmlElement newChild = , Boolean throwOnError = True)
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T child = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerXml()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

RunProperties

We found 10 examples in language CSharp for this search. You will see 50 fragments of code.

		public void AddCards(Table table, List<StoryCard> storyCardList)
		{
			int maxY = GetY(storyCardList.Count);

			int cardsCreated = 0;
			for (int y = 0; y <= maxY; y++)
			{
				List<TableRow> currentRows = new List<TableRow>();
				int maxX = GetX(storyCardList.Count - cardsCreated);
				for (int x = 0; x < maxX; x++)
				{
					for (int rowIndex = 0; rowIndex < originalRows.Length; rowIndex++)
					{
						var row = originalRows[rowIndex];

						TableRow currentRow;
						if (x == 0)
						{
							currentRow = (TableRow)row.CloneNode(true);
							currentRow.RemoveAllChildren<TableCell>();
							currentRows.Add(currentRow);
							table.AppendChild(currentRow);
						}
						else
							currentRow = currentRows[rowIndex];

						var rowCells = originalCells[rowIndex];
						foreach (var cell in rowCells)
						{
							TableCell clonedCell = (TableCell)cell.CloneNode(true);
							currentRow.AppendChild(clonedCell);
							AddTextToBookmark(clonedCell, storyCardList[cardsCreated]);
						}
					}
					cardsCreated++;
				}
			}

			var properties = table.Descendants<TableProperties>().First();
			var oldWidth = properties.TableWidth;
			var newWidth = Convert.ToInt32(oldWidth.Width.Value) * GetX(storyCardList.Count);

			properties.TableWidth = new TableWidth { Width = newWidth.ToString(CultureInfo.InvariantCulture) };
		}

		private void AddTextToBookmark(TableCell cell, StoryCard storyCard)
		{
			var bookmark = cell.Descendants<BookmarkStart>().First();

			if (bookmark.Name == "Id")
				AppendText(storyCard.Id.ToString(), bookmark);
			else if (bookmark.Name == "Iteration")
				AppendText(storyCard.Iteration, bookmark);
			else if (bookmark.Name == "Titel")
				AppendText(storyCard.Title, bookmark);
		}

		private static void AppendText(string textValue, BookmarkStart bookmark)
		{
			var idParagraph = bookmark.Parent;

			Text text = new Text();
			text.Text = textValue;

			List<OpenXmlElement> siblings = new List<OpenXmlElement>();
			OpenXmlElement sibling = bookmark.NextSibling();
			while (sibling != null && !(sibling is BookmarkEnd))
			{
				siblings.Add(sibling);
				sibling = sibling.NextSibling();
			}

			var runSibling = bookmark.NextSibling<Run>();
			var runProperties = GetRunProperties(runSibling);

			foreach (var s in siblings)
				idParagraph.RemoveChild(s);

			var run = new Run();
			if (runProperties != null)
				run.AppendChild(runProperties);
			run.AppendChild(text);
			idParagraph.AppendChild(run);
		}

		private static RunProperties GetRunProperties(Run nextSibling)
		{
			var runProperties = nextSibling.Descendants<RunProperties>().FirstOrDefault();
			if (runProperties != null)
				runProperties = (RunProperties)runProperties.CloneNode(true);
			return runProperties;
		}

		private int GetX(int cardsLeft)
		{
			var x = cardsLeft < maxColumns ? cardsLeft : maxColumns;
			return x;
		}

		private int GetY(int cardsCount)
		{
			int maxX = GetX(cardsCount);
			var y = cardsCount / maxX;
			return y;
		}

        [Test]
        public void RunComparerTest()
        {
            var a = new Run();
            var b = new Run();
            Assert.IsTrue(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerHappyTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            Assert.IsTrue(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Text("Test"));
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerChildrenWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunComparerPropertiesWrongTest()
        {
            var a = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties { Bold = new Bold { Val = true } } };
            var b = new Run(new Break(), new Text("Test")) { RunProperties = new RunProperties () };
            Assert.IsFalse(new RunComparer(a, b).Compare());
        }

        [Test]
        public void RunPropertiesComparerEmptyTest()
        {
            var a = new RunProperties();
            var b = new RunProperties();
            var runPropertiesComparer = new RunPropertiesComparer(a, b);
            Assert.IsTrue(runPropertiesComparer.Compare());
        }

        [Test]
        public void RunPropertiesComparerTest()
        {
            var a = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = true } };
            var b = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = true }  };
            var runPropertiesComparer = new RunPropertiesComparer(a, b);
            Assert.IsTrue(runPropertiesComparer.Compare());

            var a1 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = true} });
            var b1 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = true} });
            Assert.IsTrue(new RunPropertiesComparer(a1, b1).Compare());

            var a2 = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = false } };
            var b2 = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}  };
            Assert.IsTrue(new RunPropertiesComparer(a2, b2).Compare());

            var a3 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = false} });
            var b3 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong} });
            Assert.IsTrue(new RunPropertiesComparer(a3, b3).Compare());

        }

        [Test]
        public void RunPropertiesComparerBNullTest()
        {
            var a = new RunProperties();
            var runPropertiesComparer = new RunPropertiesComparer(a, null);
            Assert.IsTrue(runPropertiesComparer.Compare());
        }

        [Test]
        public void RunPropertiesComparerWrongTest()
        {
            var a = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = true } };
            var b = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = false }  };
            var runPropertiesComparer = new RunPropertiesComparer(a, b);
            Assert.IsFalse(runPropertiesComparer.Compare());

            var a1 = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}, Italic = new Italic{ Val = true } };
            var b1 = new RunProperties { Underline = new Underline{Val = UnderlineValues.DashLong}};
            Assert.IsFalse(new RunPropertiesComparer(a1, b1).Compare());

            var a2 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = true} });
            var b2 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = false} });
            Assert.IsFalse(new RunPropertiesComparer(a2, b2).Compare());

            var a3 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong}, new Bold {Val = true} });
            var b3 = new RunProperties (new List<OpenXmlElement> { new Underline{Val = UnderlineValues.DashLong} });
            Assert.IsFalse(new RunPropertiesComparer(a3, b3).Compare());
        }

        [TestCase("<!--<p>some text</p>-->")]
        [TestCase("<script>$.appendTo('<p>some text</p>', document);</script>")]
        public void ParseIgnore(string html)
        {
            // the inner html shouldn't be interpreted
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(0));
        }

        [Test]
        public void ParseUnclosedTag()
        {
            var elements = converter.Parse("<p>some text in <i>italics <b>,bold and italics</p>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            var runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[0].ChildElements[2].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            elements = converter.Parse("<p>First paragraph in semi-<i>italics <p>Second paragraph still italic <b>but also in bold</b></p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(2));

            runProperties = elements[0].ChildElements[0].GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);

            runProperties = elements[0].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(false));

            runProperties = elements[1].ChildElements[1].GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.That(runProperties.HasChild<Italic>(), Is.EqualTo(true));
            Assert.That(runProperties.HasChild<Bold>(), Is.EqualTo(true));

            // this should generate a new paragraph with its own style
            elements = converter.Parse("<p>First paragraph in <i>italics </i><p>Second paragraph not in italic</p>");
            Assert.That(elements.Count, Is.EqualTo(2));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(2));
            Assert.That(elements[1].ChildElements.Count, Is.EqualTo(1));
            Assert.That(elements[1].FirstChild, Is.TypeOf(typeof(Run)));

            runProperties = elements[1].FirstChild.GetFirstChild<RunProperties>();
            Assert.IsNull(runProperties);
        }

        [TestCase("<p>Some\ntext</p>", ExpectedResult = 1)]
        [TestCase("<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("\t<p>Some <b>bold\n</b>text</p>", ExpectedResult = 3)]
        [TestCase("  <p>Some text</p> ", ExpectedResult = 1)]
        public int ParseNewline (string html)
        {
            var elements = converter.Parse(html);
            return elements[0].ChildElements.Count;
        }

        [Test]
        public void ParseDisorderedTable ()
        {
            // table parts should be reordered
            var elements = converter.Parse(@"
<table>
<tbody>
    <tr><td>Body</td></tr>
</tbody>
<thead>
    <tr><td>Header</td></tr>
</thead>
<tfoot>
    <tr><td>Footer</td></tr>
</tfoot>
</table>");

            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0], Is.TypeOf(typeof(Table)));

            var rows = elements[0].Elements<TableRow>();
            Assert.That(rows.Count(), Is.EqualTo(3));
            Assert.That(rows.ElementAt(0).InnerText, Is.EqualTo("Header"));
            Assert.That(rows.ElementAt(1).InnerText, Is.EqualTo("Body"));
            Assert.That(rows.ElementAt(2).InnerText, Is.EqualTo("Footer"));
        }

        [Test]
        public void ParseNotTag ()
        {
            var elements = converter.Parse(" < b >bold</b>");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());

            elements = converter.Parse(" <3");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(1));
            Assert.IsNull(elements[0].FirstChild.GetFirstChild<RunProperties>());
        }

        [Test]
        public void ParseNewlineFlow ()
        {
            // the new line should generate a space between "bold" and "text"
            var elements = converter.Parse(" <span>This is a <b>bold\n</b>text</span>");
        }


        [HttpPost]
        public async Task<IActionResult> GenerateDocument([FromBody] InsuranceDocumentDetails documentDetails)
        {
            try
            {

                //string filePath = Environment.CurrentDirectory + @"\\Documents\\" + documentDetails[0].clientDetails.FamilyName.ToString().Trim() + "," + documentDetails[0].clientDetails.ClientName.ToString().Trim() + "-" + documentDetails[0].clientDetails.ClientId.ToString().Trim() + ".docx";
                MemoryStream ms = new MemoryStream();
                string _storageConnection = Configuration.GetConnectionString("StorageConnectionString");
                CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(_storageConnection);
                CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
                CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("plstorage");

                if (await cloudBlobContainer.CreateIfNotExistsAsync())
                {
                    await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions
                    {
                        PublicAccess = BlobContainerPublicAccessType.Blob
                    });
                }
                string filePath = documentDetails.clientDetails.FamilyName.ToString().Trim() + "," + documentDetails.clientDetails.ClientName.ToString().Trim() + "-" + documentDetails.clientDetails.ClientId.ToString().Trim() + "-Insurance.docx";

                CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(filePath);
                using (WordprocessingDocument package = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document))
                {

                    MainDocumentPart mainPart = package.AddMainDocumentPart();
                    mainPart.Document = new Document();
                    Body body = mainPart.Document.AppendChild(new Body());
                    SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "008818E9", RsidR = "00543A0D" };
                    FooterReference footerReference1 = new FooterReference() { Type = HeaderFooterValues.Default, Id = "rId8" };

                    sectionProperties1.Append(footerReference1);

                    body.Append(sectionProperties1);





                    NumberingDefinitionsPart numberinfPart = mainPart.AddNewPart<NumberingDefinitionsPart>("numbering");
                    Numbering element = new Numbering(new AbstractNum(new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "•" }, new LevelJustification { Val = LevelJustificationValues.Left }, new ParagraphProperties(new Indentation { Left = "720", Hanging = "360" })) { LevelIndex = 0 }) { AbstractNumberId = 0 }, new NumberingInstance(new AbstractNumId() { Val = 0 }) { NumberID = 1 });
                    element.Save(numberinfPart);

                    Color orange = new Color() { Val = "ED7D27" };

                    //Your Risk Protection

                    var clientCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Client");
                    var partnerCurrentInsurance = documentDetails.currentInsurance.Where(x => x.Owner == "Partner");

                    if (clientCurrentInsurance.Count() > 0 || partnerCurrentInsurance.Count() > 0)
                    {
                        if (clientCurrentInsurance.Count() > 0)
                        {
                                  AddRiskProtection(body, documentDetails.clientDetails, clientCurrentInsurance, orange, 0);
                        }

                        if (partnerCurrentInsurance.Count() > 0)
                        {
                                     AddRiskProtection(body, documentDetails.clientDetails, partnerCurrentInsurance, orange, 1);
                        }
                    }

                    Paragraph break2 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break2);

                    //Paragraph pr0 = new Paragraph();
                    //add(pr0);
                    //body.Append(pr0);

                       GenerateBody(body);
                    Run br1 = new Run(new Break());
                    Paragraph pr1 = new Paragraph();
                    pr1.Append(new OpenXmlElement[] { br1 });
                    body.Append(pr1);

                       AddPara1(body);
                    //Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    //pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);
                        AddPara2(body);

                    //Your Insurance Needs

                    Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break3);

                    var clientNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Client");
                    var partnerNeedsAnalysis = documentDetails.needsAnalysis.Where(x => x.Owner == "Partner");

                    if (clientNeedsAnalysis.Count() > 0 || partnerNeedsAnalysis.Count() > 0)
                    {
                        Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Your Insurance Needs")));
                        body.Append(InsuranceNeeds);


                        if (clientNeedsAnalysis.Count() > 0)
                        {
                                AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                        }

                        if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                        {
                                  AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                        }

                    }


                    //Recommended Insurance
                    body.AppendChild(break3.CloneNode(true));
                    var clientProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Client");
                    var partnerProposedInsurance = documentDetails.proposedInsurance.Where(x => x.Owner == "Partner");

                    if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    {
                        if (clientProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, clientProposedInsurance, orange, 0);
                        }

                        if (partnerProposedInsurance.Count() > 0)
                        {
                                     AddRecommendedInsurance(body, documentDetails.clientDetails, partnerProposedInsurance, orange, 1);
                        }


                              AddStandardText(body, orange);
                    }

                    //Insurance ROP

                         AddReplacementOfProduct(body, documentDetails.currentInsurance, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    body.Append(break4);


                        AddImplementation(body, documentDetails.proposedInsurance, documentDetails.clientDetails, orange);

                    //Paragraph break4 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));
                    //body.Append(break4);


                    //if (clientProposedInsurance.Count() > 0 || partnerProposedInsurance.Count() > 0)
                    //{
                    //    Paragraph InsuranceNeeds = new Paragraph(new Run(new RunProperties(new Color() { Val = "ED7D27" }, new FontSize { Val = "40" }), new Text("Insurance replacement of product")));
                    //    body.Append(InsuranceNeeds);


                    //    if (clientNeedsAnalysis.Count() > 0)
                    //    {
                    //        AddInsuranceNeeds(body, clientNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.ClientName);
                    //    }

                    //    if (partnerNeedsAnalysis.Count() > 0 && documentDetails.clientDetails.MaritalStatus != "S")
                    //    {
                    //        AddInsuranceNeeds(body, partnerNeedsAnalysis.ToArray(), orange, documentDetails.clientDetails.PartnerName);
                    //    }

                    //}

                    //Footer
                    var t = mainPart.Document.Body.Descendants<Table>().ToList();
                    var p = mainPart.Document.Body.Descendants<Paragraph>().ToList();
                    AlterTableType(t, p, package);

                    FooterPart footerPart = mainPart.AddNewPart<FooterPart>();

                    string footerPartId = mainPart.GetIdOfPart(footerPart);
                        GeneratePartContent(footerPart);

                    IEnumerable<SectionProperties> sections = mainPart.Document.Body.Elements<SectionProperties>();
                    foreach (var section in sections)
                    {
                        section.RemoveAllChildren<FooterReference>();
                        section.PrependChild<FooterReference>(new FooterReference() { Id = footerPartId });
                    }


                    package.MainDocumentPart.Document.Save();
                    package.Close();

                }


                ms.Position = 0;
                await blockBlob.UploadFromStreamAsync(ms);


                return File(ms.ToArray(), "application/octet-stream", "test");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void AddImplementation(Body body, ProposedInsuranceViewModel[] proposedInsurance, BasicDetails clientDetails, Color orange)
        {

            var implementation = new List<ProposedInsuranceViewModel>();
            var ongoing = new List<ProposedInsuranceViewModel>();

            foreach (ProposedInsuranceViewModel pI in proposedInsurance)
            {
                if (pI.Implementation.Commission > 0)
                {
                    implementation.Add(pI);
                }
                if (pI.Ongoing.Commission > 0)
                {
                    ongoing.Add(pI);
                }
            }

            if (implementation.Count() > 0 || ongoing.Count() > 0)
            {

                if (implementation.Any())
                {

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Implementation"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("If you wish to proceed with our advice, the following table shows the costs that apply to implement our recommendations."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in implementation)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }

                if (ongoing.Any())
                {

                    Run br2 = new Run(new Break());
                    Paragraph pr2 = new Paragraph();
                    pr2.Append(new OpenXmlElement[] { br2 });
                    body.Append(pr2);

                    Paragraph s1 = body.AppendChild(new Paragraph());
                    Run r1 = s1.AppendChild(new Run());
                    RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
                    Color black = new Color() { Val = "000000" };
                    runProperties1.AppendChild(orange.CloneNode(true));
                    r1.AppendChild(new Text("Ongoing advice"));

                    Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The following table shows the ongoing costs. All fees are shown as annual amounts."))));

                    //New Table

                    Table table = body.AppendChild(new Table());
                    TableProperties tableProp = new TableProperties();
                    TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                    TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                    tableProp.Append(tableStyle, tableWidth);
                    table.AppendChild(tableProp);


                    ////Header
                    TableRow type = new TableRow();

                    TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties hcp2 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    ParagraphProperties hpp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties hpp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                    Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                    hpp1.AppendChild((Justification)centerJustify.CloneNode(true));

                    TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                    Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                    TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    hcp.Append(hcm1, hs1, hcb);
                    hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                    hcp2.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true));

                    TableCell blank = new TableCell();
                    blank.AppendChild((ParagraphProperties)hpp.CloneNode(true));
                    blank.Append((TableCellProperties)hcp2.CloneNode(true));
                    blank.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Description"))));
                    type.Append(blank);


                    TableCell h = new TableCell();
                    h.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h.Append((TableCellProperties)hcp2.CloneNode(true));
                    h.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Cost to you"))));
                    type.Append(h);

                    TableCell h1 = new TableCell();
                    h1.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h1.Append((TableCellProperties)hcp2.CloneNode(true));
                    h1.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Calculation of amounts received by us"))));
                    type.Append(h1);

                    TableCell h2 = new TableCell();
                    h2.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h2.Append((TableCellProperties)hcp2.CloneNode(true));
                    h2.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("RI Advice Group"))));
                    type.Append(h2);

                    TableCell h3 = new TableCell();
                    h3.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h3.Append((TableCellProperties)hcp2.CloneNode(true));
                    h3.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Practice"))));
                    type.Append(h3);

                    TableCell h4 = new TableCell();
                    h4.AppendChild((ParagraphProperties)hpp1.CloneNode(true));
                    h4.Append((TableCellProperties)hcp2.CloneNode(true));
                    h4.Append(new Paragraph(new Run(new RunProperties(new Bold(), new FontSize { Val = new StringValue("16") }), new Text("Adviser"))));
                    type.Append(h4);

                    table.Append(type);


                    //Body

                    TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                    TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                    TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                    TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                    TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                    ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                    ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });


                    pp1.AppendChild((Justification)centerJustify.CloneNode(true));
                    tcp.Append(tcbL, tcm);
                    tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));

                    decimal totalFeeCost = 0;
                    decimal totalAdviceGroup = 0;
                    decimal totalPractice = 0;

                    foreach (ProposedInsuranceViewModel proposed in ongoing)
                    {

                        TableRow heading = new TableRow();
                        TableCell bACell = new TableCell();
                        TableCellProperties tableCellProperties9 = new TableCellProperties(new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, new GridSpan() { Val = 6 });
                        tableCellProperties9.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));
                        bACell.Append(tableCellProperties9);
                        bACell.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        bACell.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Owner == "Client" ? clientDetails.ClientName + " - " + proposed.Provider : clientDetails.PartnerName + " - " + proposed.Provider))));
                        heading.Append(bACell);
                        table.Append(heading);

                        TableRow impDetails = new TableRow();

                        TableCell tableCell1 = new TableCell();
                        tableCell1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tableCell1.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell1.Append(new Paragraph(new Run(new RunProperties(), new Text("Premium paid by you your super fund to insurer. Commission paid by insurer to us, after implementation of strategy"))));
                        impDetails.Append(tableCell1);

                        var feeSum = proposed.FeeDetails.Sum(x => x.Amount);
                        //verify if error
                        var adviceGroup = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Riadvice / 100);
                        var practice = feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Practice / 100);
                        var adviser = proposed.Implementation.Adviser == 0 ? "See note above" : string.Format("{0:n0}", feeSum * (proposed.Implementation.Commission / 100) * (proposed.Implementation.Adviser / 100));


                        totalFeeCost += feeSum;
                        totalAdviceGroup += adviceGroup;
                        totalPractice += practice;


                        TableCell tableCell2 = new TableCell();
                        tableCell2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell2.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell2.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", feeSum)))));
                        impDetails.Append(tableCell2);

                        TableCell tableCell3 = new TableCell();
                        tableCell3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell3.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell3.Append(new Paragraph(new Run(new RunProperties(new FontSize { Val = new StringValue("16") }), new Text(proposed.Implementation.Commission + "% of commissionable premium"))));
                        impDetails.Append(tableCell3);



                        TableCell tableCell4 = new TableCell();
                        tableCell4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell4.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell4.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", adviceGroup)))));
                        impDetails.Append(tableCell4);

                        TableCell tableCell5 = new TableCell();
                        tableCell5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell5.Append((TableCellProperties)tcp.CloneNode(true));
                        tableCell5.Append(new Paragraph(new Run(new RunProperties(), new Text(string.Format("{0:n0}", practice)))));
                        impDetails.Append(tableCell5);

                        TableCell tableCell6 = new TableCell();
                        tableCell6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tableCell6.Append((TableCellProperties)tcpN.CloneNode(true));
                        tableCell6.Append(new Paragraph(new Run(new RunProperties(), new Text(adviser))));
                        impDetails.Append(tableCell6);

                        table.Append(impDetails);


                    }


                    TableRow totalRow = new TableRow();

                    TableCell total1 = new TableCell();
                    total1.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    total1.Append((TableCellProperties)tcp.CloneNode(true));
                    total1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("Totals"))));
                    totalRow.Append(total1);

                    TableCell total2 = new TableCell();
                    total2.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total2.Append((TableCellProperties)tcp.CloneNode(true));
                    total2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalFeeCost)))));
                    totalRow.Append(total2);

                    TableCell total3 = new TableCell();
                    total3.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total3.Append((TableCellProperties)tcp.CloneNode(true));
                    total3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total3);

                    TableCell total4 = new TableCell();
                    total4.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total4.Append((TableCellProperties)tcp.CloneNode(true));
                    total4.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalAdviceGroup)))));
                    totalRow.Append(total4);

                    TableCell total5 = new TableCell();
                    total5.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total5.Append((TableCellProperties)tcp.CloneNode(true));
                    total5.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text("$" + string.Format("{0:n0}", totalPractice)))));
                    totalRow.Append(total5);

                    TableCell total6 = new TableCell();
                    total6.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    total6.Append((TableCellProperties)tcpN.CloneNode(true));
                    total6.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                    totalRow.Append(total6);


                    table.Append(totalRow);
                }
            }


        }

        private void AddStandardText(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            r1.AppendChild(new Text("Other important information"));

            Paragraph p1 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("The recommended insurance cover may have exclusions applied, be loaded (higher premiums) or be declined depending on the outcome of underwriting."))));
            Paragraph p2 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("A death benefit will not be paid in the first 13 months of your life policy in the event of death by suicide."))));
            Paragraph p3 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Your policy has a cooling off period which allows you to cancel your cover and receive a refund of premiums paid. Please refer to the PDS for details."))));


            Paragraph s2 = body.AppendChild(new Paragraph());
            Run r2 = s2.AppendChild(new Run());
            RunProperties runProperties2 = r2.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties2.AppendChild(orange.CloneNode(true));
            r2.AppendChild(new Text("Your duty of disclosure"));

            Paragraph p5 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Before you apply for, extend, renew, vary or reinstate your insurance, it is important that you understand your duty of disclosure. The key elements are:"))));

            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You have a duty under law to disclose to the insurer every matter you know or could reasonably be expected to know that is relevant to their decision to accept your insurance application."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You must provide all the information requested by the insurer. Your duty could also extend beyond the questions in the insurance application form."))));
            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Your duty continues until the insurance application is accepted. You will need to disclose any relevant changes in your circumstances that occur before the insurance policy is issued."))));
            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("If you do not comply with your duty of disclosure, in some circumstances, your insurance may be avoided or varied, or future claims may be affected or denied. "))));

            Paragraph p6 = body.AppendChild(new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please refer to the relevant PDS for full details about your duty of disclosure."))));

            //Paragraph br = body.AppendChild(new Paragraph(new Run(new Break())));

            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Product Disclosure Statement of retained policies"));

            Color red = new Color() { Val = "FF0000" };

            Paragraph p7 = new Paragraph(new Run(new RunProperties(new Color() { Val = "000000" }), new Text("Please read the following Product Disclosure Statement (PDS) for further information on your retained insurance ")));
            p7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " [policy/ies:] ", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(p7);

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[PDS name here]"))));

        }

        private void AddStandardTextROP(Body body, Color orange)
        {
            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));
            Color red = new Color() { Val = "FF0000" };
            r1.AppendChild(new Text("Product replacement recommendations"));


            Paragraph commentary = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("Based on our research and your needs and objectives, our recommendation is to replace your current insurance product."))));
            Paragraph commentary1 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Recommended product]"))));
            commentary1.Append(new Run(new RunProperties(), new Text { Text = " was deemed appropriate for you because: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary2 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If superior features]"))));
            commentary2.Append(new Run(new RunProperties(), new Text { Text = " It provides you with additional features. ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary3 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[If lower premiums]"))));
            commentary3.Append(new Run(new RunProperties(), new Text { Text = " You will benefit from lower premiums. ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph commentary6 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("In making this recommendation, we compared "))));
            commentary6.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = " recommended product ", Space = SpaceProcessingModeValues.Preserve }));
            commentary6.Append(new Run(new RunProperties(), new Text { Text = "to the following other products in the market: ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary7 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 1]"))));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = " could ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[save you $XXX in annual costs and you would benefit from XXX features.]  ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties(), new Text { Text = "However we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary7.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[you specifically stated you wanted the XXX product.] ", Space = SpaceProcessingModeValues.Preserve }));

            Paragraph commentary8 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new Indentation() { Left = "1080" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties((Color)red.CloneNode(true)), new Text("[Alternative product 2]"))));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = " offers ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[XXX features which could benefit you]", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties(), new Text { Text = ", however we disregarded this product because ", Space = SpaceProcessingModeValues.Preserve }));
            commentary8.Append(new Run(new RunProperties((Color)red.CloneNode(true)), new Text { Text = "[the annual costs are around $XXX more than XXX recommended product and this is more than you want to pay.] ", Space = SpaceProcessingModeValues.Preserve }));


            Paragraph s3 = body.AppendChild(new Paragraph());
            Run r3 = s3.AppendChild(new Run());
            RunProperties runProperties3 = r3.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));

            // runProperties3.AppendChild(orange.CloneNode(true));
            r3.AppendChild(new Text("Important note:"));

            Paragraph commentary4 = body.AppendChild(new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("You should maintain your existing cover until the new policy is established, and all waiting periods are served, to ensure you have continuous cover. This could mean you are paying multiple premiums for a period of time. Once your new policy is in place and all waiting periods have been satisfied, the old policy can be cancelled."))));
            Paragraph commentary5 = new Paragraph(new ParagraphProperties(new ParagraphStyleId() { Val = "ListParagraph" }, new NumberingProperties(new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = 1 })), new Run(new RunProperties(), new Text("A policy that has been in force for three years or longer may have a greater level of protection against avoidance by an insurer if the duty of disclosure is breached or innocent misrepresentation occurs.")));
            commentary5.Append(new Run(new RunProperties(new Bold()), new Text { Text = " Cancelling your existing cover to take out new cover will restart this three year period where the insurer could avoid your policy if innocent non-disclosure or misrepresentation occurs.", Space = SpaceProcessingModeValues.Preserve }));
            body.Append(commentary5);
        }

        private void AddRecommendedInsurance(Body body, BasicDetails clientDetails, IEnumerable<ProposedInsuranceViewModel> clientProposedInsurance, Color orange, int v)
        {
            Paragraph break3 = new Paragraph(new Run(new Break() { Type = BreakValues.Page }));

            Paragraph s1 = body.AppendChild(new Paragraph());
            Run r1 = s1.AppendChild(new Run());
            RunProperties runProperties1 = r1.AppendChild(new RunProperties(new Bold(), new RunFonts { Ascii = "Verdana" }, new FontSize { Val = new StringValue("20") }));
            Color black = new Color() { Val = "000000" };
            runProperties1.AppendChild(orange.CloneNode(true));

            if (v == 0)
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.ClientName));
            }
            else
            {
                r1.AppendChild(new Text("Recommended Insurance cover for " + clientDetails.PartnerName));
            }


            foreach (ProposedInsuranceViewModel proposed in clientProposedInsurance)
            //New Table
            {
                Table table = body.AppendChild(new Table());
                TableProperties tableProp = new TableProperties();
                TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

                TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

                tableProp.Append(tableStyle, tableWidth);
                table.AppendChild(tableProp);


                ////Header
                TableRow header = new TableRow();
                TableCell h1 = new TableCell();

                TableCellProperties hcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties hcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                ParagraphProperties hppLeft = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppCenter = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });
                ParagraphProperties hppRight = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "5" });

                Justification centerJustify = new Justification() { Val = JustificationValues.Center };
                hppCenter.AppendChild((Justification)centerJustify.CloneNode(true));

                Justification rightJustify = new Justification() { Val = JustificationValues.Right };
                hppRight.AppendChild((Justification)rightJustify.CloneNode(true));

                Justification leftJustify = new Justification() { Val = JustificationValues.Left };

                TableCellBorders hcb = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 20, Color = "ED7D27" } };

                Shading hs1 = new Shading() { Color = "auto", Fill = "393939", Val = ShadingPatternValues.Clear };
                TableCellMargin hcm1 = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                hcp.Append(hcm1, hs1, hcb);
                //hcp1.Append((TableCellMargin)hcm1.CloneNode(true), (Shading)hs1.CloneNode(true), (TableCellBorders)hcb.CloneNode(true));
                h1.Append(hcp);

                h1.AppendChild((ParagraphProperties)hppLeft.CloneNode(true));

                var heading = "";
                if (proposed.ReplacementId == 0)
                {
                    heading = "Purchase";
                }
                else
                {
                    heading = "";
                }

                h1.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(heading))));

                TableCell h2 = new TableCell();
                h2.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h2.Append((TableCellProperties)hcp.CloneNode(true));
                h2.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(proposed.Provider))));

                TableCell h3 = new TableCell();
                h3.AppendChild((ParagraphProperties)hppCenter.CloneNode(true));
                h3.Append((TableCellProperties)hcp.CloneNode(true));
                h3.Append(new Paragraph(new Run(new RunProperties(new Bold()), new Text(""))));
                header.Append(h1, h2, h3);

                table.Append(header);
                //Body
                TableCellProperties tcp1 = new TableCellProperties(new TableCellWidth { Width = "2390", Type = TableWidthUnitValues.Auto }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcp = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });
                TableCellProperties tcpN = new TableCellProperties(new TableCellWidth { Width = "2000", Type = TableWidthUnitValues.Pct }, new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center });

                TableCellBorders tcbL = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, RightBorder = new RightBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbR = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, LeftBorder = new LeftBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };
                TableCellBorders tcbN = new TableCellBorders() { BottomBorder = new BottomBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" }, TopBorder = new TopBorder() { Val = BorderValues.Single, Size = 1, Color = "D3D3D3" } };

                TableCellMargin tcm = new TableCellMargin() { RightMargin = new RightMargin() { Width = "50", Type = TableWidthUnitValues.Dxa }, LeftMargin = new LeftMargin() { Width = "50", Type = TableWidthUnitValues.Dxa } };

                ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp1 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });
                ParagraphProperties pp2 = new ParagraphProperties(new ParagraphStyleId() { Val = "No Spacing" }, new SpacingBetweenLines() { After = "0" });

                pp2.AppendChild((Justification)rightJustify.CloneNode(true));
                pp.AppendChild((Justification)leftJustify.CloneNode(true));
                tcp.Append(tcbL, tcm);
                tcpN.Append((TableCellBorders)tcbN.CloneNode(true), (TableCellMargin)tcm.CloneNode(true));


                if (proposed.LifeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Life")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.LifeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.LifeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));



                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.LifeCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.LifeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.LifeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.LifeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TpdCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("TPD")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TpdCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TpdCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TpdCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TpdCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TpdCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TpdCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.TraumaCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Trauma")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.TraumaCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.TraumaCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.TraumaCover.First().BenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.TraumaCover.First().BenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }


                    if (proposed.TraumaCover.First().StandaloneOrLinked != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Stand Alone / Linked"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().StandaloneOrLinked))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.TraumaCover.First().WithinSuper != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.TraumaCover.First().WithinSuper))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }

                if (proposed.IncomeCover.Count() > 0)
                {

                    TableRow mtr = new TableRow();
                    TableCell mtc1 = new TableCell();

                    tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                    mtc1.Append((TableCellProperties)tcp.CloneNode(true));
                    mtc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                    mtc1.Append(new Paragraph(new Run(new Text(""))));

                    TableCell mtc2 = new TableCell();
                    mtc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc2.Append((TableCellProperties)tcp1.CloneNode(true));
                    mtc2.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Cover Type")))));

                    TableCell mtc3 = new TableCell();
                    mtc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                    mtc3.Append((TableCellProperties)tcpN.CloneNode(true));
                    mtc3.Append(new Paragraph(new Run(new Run(new RunProperties(new Bold()), new Text("Income Protection")))));

                    mtr.Append(mtc1, mtc2, mtc3);

                    table.AppendChild(mtr);

                    if (proposed.IncomeCover.First().PolicyOwner != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Policy Owner"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PolicyOwner == "Client" ? clientDetails.ClientName : (proposed.IncomeCover.First().PolicyOwner == "Partner" ? clientDetails.PartnerName : "Super Fund")))));


                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().MonthlyBenefitAmount != 0)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Amount"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text("$" + String.Format("{0:n}", proposed.IncomeCover.First().MonthlyBenefitAmount.ToString())))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }

                    if (proposed.IncomeCover.First().Definition != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Definition"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().Definition))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WaitingPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Waiting Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WaitingPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().BenefitPeriod != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Benefit Period"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().BenefitPeriod))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().PremiumType != "")
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Premium Type"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().PremiumType))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                    if (proposed.IncomeCover.First().WithinSuper < 2)
                    {
                        TableRow tr = new TableRow();
                        TableCell tc1 = new TableCell();

                        tcp1.Append((TableCellBorders)tcbL.CloneNode(true), (TableCellMargin)tcm.CloneNode(true), (Justification)centerJustify.CloneNode(true));
                        tc1.Append((TableCellProperties)tcp.CloneNode(true));
                        tc1.AppendChild((ParagraphProperties)pp1.CloneNode(true));
                        tc1.Append(new Paragraph(new Run(new Text(""))));

                        TableCell tc2 = new TableCell();
                        tc2.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc2.Append((TableCellProperties)tcp1.CloneNode(true));
                        tc2.Append(new Paragraph(new Run(new Text("Super"))));

                        TableCell tc3 = new TableCell();
                        tc3.AppendChild((ParagraphProperties)pp.CloneNode(true));
                        tc3.Append((TableCellProperties)tcpN.CloneNode(true));
                        tc3.Append(new Paragraph(new Run(new Text(proposed.IncomeCover.First().WithinSuper == 1 ? "Yes" : "No"))));

                        tr.Append(tc1, tc2, tc3);

                        table.AppendChild(tr);
                    }
                }


                Run linebreak = new Run(new Break());
                Paragraph productCost = new Paragraph();
                productCost.Append(new OpenXmlElement[] { (Run)linebreak.CloneNode(true), new Run(new RunProperties(new Bold()), new Text("Please note the following: ")) });
                body.Append(productCost);

            }
        }

        private void add(Paragraph body)
        {
            AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice() { Requires = "wps" };

            W.Drawing drawing1 = new W.Drawing();

            Wp.Anchor anchor1 = new Wp.Anchor() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)114935U, DistanceFromRight = (UInt32Value)114935U, SimplePos = false, RelativeHeight = (UInt32Value)251676672U, BehindDoc = true, Locked = false, LayoutInCell = true, AllowOverlap = true, EditId = "3A313D92", AnchorId = "5438FE6E" };
            Wp.SimplePosition simplePosition1 = new Wp.SimplePosition() { X = 0L, Y = 0L };

            Wp.HorizontalPosition horizontalPosition1 = new Wp.HorizontalPosition() { RelativeFrom = Wp.HorizontalRelativePositionValues.Column };
            Wp.PositionOffset positionOffset1 = new Wp.PositionOffset();
            positionOffset1.Text = "6030595";

            horizontalPosition1.Append(positionOffset1);

            Wp.VerticalPosition verticalPosition1 = new Wp.VerticalPosition() { RelativeFrom = Wp.VerticalRelativePositionValues.Paragraph };
            Wp.PositionOffset positionOffset2 = new Wp.PositionOffset();
            positionOffset2.Text = "97155";

            verticalPosition1.Append(positionOffset2);
            Wp.Extent extent1 = new Wp.Extent() { Cx = 35560L, Cy = 13970L };
            Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 8255L, TopEdge = 5715L, RightEdge = 3810L, BottomEdge = 8890L };
            Wp.WrapNone wrapNone1 = new Wp.WrapNone();
            Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = (UInt32Value)92U, Name = "Text Box 92" };

            Wp.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Wp.NonVisualGraphicFrameDrawingProperties();

            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks();
            graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            A.Graphic graphic1 = new A.Graphic();
            graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" };

            Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape();

            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties() { TextBox = true };
            A.ShapeLocks shapeLocks1 = new A.ShapeLocks() { NoChangeArrowheads = true };

            nonVisualDrawingShapeProperties1.Append(shapeLocks1);

            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto };

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
            A.Extents extents1 = new A.Extents() { Cx = 35560L, Cy = 13970L };

            transform2D1.Append(offset1);
            transform2D1.Append(extents1);

            A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "FFFFFF" };
            A.Alpha alpha1 = new A.Alpha() { Val = 0 };

            rgbColorModelHex1.Append(alpha1);

            solidFill1.Append(rgbColorModelHex1);

            A.Outline outline1 = new A.Outline();
            A.NoFill noFill1 = new A.NoFill();

            outline1.Append(noFill1);

            A.ShapePropertiesExtensionList shapePropertiesExtensionList1 = new A.ShapePropertiesExtensionList();

            A.ShapePropertiesExtension shapePropertiesExtension1 = new A.ShapePropertiesExtension() { Uri = "{91240B29-F687-4F45-9708-019B960494DF}" };

            A14.HiddenLineProperties hiddenLineProperties1 = new A14.HiddenLineProperties() { Width = 9525 };
            hiddenLineProperties1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");

            A.SolidFill solidFill2 = new A.SolidFill();
            A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = "000000" };

            solidFill2.Append(rgbColorModelHex2);
            A.Miter miter1 = new A.Miter() { Limit = 800000 };
            A.HeadEnd headEnd1 = new A.HeadEnd();
            A.TailEnd tailEnd1 = new A.TailEnd();

            hiddenLineProperties1.Append(solidFill2);
            hiddenLineProperties1.Append(miter1);
            hiddenLineProperties1.Append(headEnd1);
            hiddenLineProperties1.Append(tailEnd1);

            shapePropertiesExtension1.Append(hiddenLineProperties1);

            shapePropertiesExtensionList1.Append(shapePropertiesExtension1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(presetGeometry1);
            shapeProperties1.Append(solidFill1);
            shapeProperties1.Append(outline1);
            shapeProperties1.Append(shapePropertiesExtensionList1);

            Wps.TextBoxInfo2 textBoxInfo21 = new Wps.TextBoxInfo2();

            W.TextBoxContent textBoxContent1 = new W.TextBoxContent();

            W.Paragraph paragraph1 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "04CE03A0", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties1 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId1 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties1 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts1 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold1 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript1 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(paragraphStyleId1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            W.Run run1 = new W.Run();

            W.RunProperties runProperties1 = new W.RunProperties();
            W.RunFonts runFonts2 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold2 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript2 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSizeComplexScript2);
            W.Text text1 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text1.Text = " ";

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            W.Paragraph paragraph2 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "6E6DB8AF", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties2 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId2 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties2 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts3 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold3 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript3 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties2.Append(runFonts3);
            paragraphMarkRunProperties2.Append(bold3);
            paragraphMarkRunProperties2.Append(fontSizeComplexScript3);

            paragraphProperties2.Append(paragraphStyleId2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            W.Run run2 = new W.Run();

            W.RunProperties runProperties2 = new W.RunProperties();
            W.RunFonts runFonts4 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold4 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript4 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(bold4);
            runProperties2.Append(fontSizeComplexScript4);
            W.Text text2 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text2.Text = " ";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);

            W.Paragraph paragraph3 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "02530E2F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties3 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId3 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties3 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts5 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold5 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript5 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties3.Append(runFonts5);
            paragraphMarkRunProperties3.Append(bold5);
            paragraphMarkRunProperties3.Append(fontSizeComplexScript5);

            paragraphProperties3.Append(paragraphStyleId3);
            paragraphProperties3.Append(paragraphMarkRunProperties3);

            W.Run run3 = new W.Run();

            W.RunProperties runProperties3 = new W.RunProperties();
            W.RunFonts runFonts6 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold6 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript6 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties3.Append(runFonts6);
            runProperties3.Append(bold6);
            runProperties3.Append(fontSizeComplexScript6);
            W.Text text3 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text3.Text = " ";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run3);

            W.Paragraph paragraph4 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4753D73F", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties4 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId4 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties4 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts7 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold7 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript7 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties4.Append(runFonts7);
            paragraphMarkRunProperties4.Append(bold7);
            paragraphMarkRunProperties4.Append(fontSizeComplexScript7);

            paragraphProperties4.Append(paragraphStyleId4);
            paragraphProperties4.Append(paragraphMarkRunProperties4);

            paragraph4.Append(paragraphProperties4);

            W.Paragraph paragraph5 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7675723D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties5 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId5 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties5 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts8 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold8 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript8 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties5.Append(runFonts8);
            paragraphMarkRunProperties5.Append(bold8);
            paragraphMarkRunProperties5.Append(fontSizeComplexScript8);

            paragraphProperties5.Append(paragraphStyleId5);
            paragraphProperties5.Append(paragraphMarkRunProperties5);

            W.Run run4 = new W.Run();

            W.RunProperties runProperties4 = new W.RunProperties();
            W.RunFonts runFonts9 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold9 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript9 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties4.Append(runFonts9);
            runProperties4.Append(bold9);
            runProperties4.Append(fontSizeComplexScript9);
            W.Text text4 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text4.Text = " ";

            run4.Append(runProperties4);
            run4.Append(text4);

            paragraph5.Append(paragraphProperties5);
            paragraph5.Append(run4);

            W.Paragraph paragraph6 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "12AC83A7", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties6 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId6 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties6 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts10 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold10 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript10 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties6.Append(runFonts10);
            paragraphMarkRunProperties6.Append(bold10);
            paragraphMarkRunProperties6.Append(fontSizeComplexScript10);

            paragraphProperties6.Append(paragraphStyleId6);
            paragraphProperties6.Append(paragraphMarkRunProperties6);

            W.Run run5 = new W.Run();

            W.RunProperties runProperties5 = new W.RunProperties();
            W.RunFonts runFonts11 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold11 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript11 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties5.Append(runFonts11);
            runProperties5.Append(bold11);
            runProperties5.Append(fontSizeComplexScript11);
            W.Text text5 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text5.Text = " ";

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph6.Append(paragraphProperties6);
            paragraph6.Append(run5);

            W.Paragraph paragraph7 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7F4349F2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties7 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId7 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties7 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts12 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold12 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript12 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties7.Append(runFonts12);
            paragraphMarkRunProperties7.Append(bold12);
            paragraphMarkRunProperties7.Append(fontSizeComplexScript12);

            paragraphProperties7.Append(paragraphStyleId7);
            paragraphProperties7.Append(paragraphMarkRunProperties7);

            W.Run run6 = new W.Run();

            W.RunProperties runProperties6 = new W.RunProperties();
            W.RunFonts runFonts13 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold13 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript13 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties6.Append(runFonts13);
            runProperties6.Append(bold13);
            runProperties6.Append(fontSizeComplexScript13);
            W.Text text6 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text6.Text = " ";

            run6.Append(runProperties6);
            run6.Append(text6);

            paragraph7.Append(paragraphProperties7);
            paragraph7.Append(run6);

            W.Paragraph paragraph8 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5378D687", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties8 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId8 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties8 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts14 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold14 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript14 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties8.Append(runFonts14);
            paragraphMarkRunProperties8.Append(bold14);
            paragraphMarkRunProperties8.Append(fontSizeComplexScript14);

            paragraphProperties8.Append(paragraphStyleId8);
            paragraphProperties8.Append(paragraphMarkRunProperties8);

            W.Run run7 = new W.Run();

            W.RunProperties runProperties7 = new W.RunProperties();
            W.RunFonts runFonts15 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold15 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript15 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties7.Append(runFonts15);
            runProperties7.Append(bold15);
            runProperties7.Append(fontSizeComplexScript15);
            W.Text text7 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text7.Text = " ";

            run7.Append(runProperties7);
            run7.Append(text7);

            paragraph8.Append(paragraphProperties8);
            paragraph8.Append(run7);

            W.Paragraph paragraph9 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5DCADE92", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties9 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId9 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties9 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts16 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold16 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript16 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties9.Append(runFonts16);
            paragraphMarkRunProperties9.Append(bold16);
            paragraphMarkRunProperties9.Append(fontSizeComplexScript16);

            paragraphProperties9.Append(paragraphStyleId9);
            paragraphProperties9.Append(paragraphMarkRunProperties9);

            W.Run run8 = new W.Run();

            W.RunProperties runProperties8 = new W.RunProperties();
            W.RunFonts runFonts17 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold17 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript17 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties8.Append(runFonts17);
            runProperties8.Append(bold17);
            runProperties8.Append(fontSizeComplexScript17);
            W.Text text8 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text8.Text = " ";

            run8.Append(runProperties8);
            run8.Append(text8);

            paragraph9.Append(paragraphProperties9);
            paragraph9.Append(run8);

            W.Paragraph paragraph10 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "4AC96599", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties10 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId10 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties10 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts18 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold18 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript18 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties10.Append(runFonts18);
            paragraphMarkRunProperties10.Append(bold18);
            paragraphMarkRunProperties10.Append(fontSizeComplexScript18);

            paragraphProperties10.Append(paragraphStyleId10);
            paragraphProperties10.Append(paragraphMarkRunProperties10);

            W.Run run9 = new W.Run();

            W.RunProperties runProperties9 = new W.RunProperties();
            W.RunFonts runFonts19 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold19 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript19 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties9.Append(runFonts19);
            runProperties9.Append(bold19);
            runProperties9.Append(fontSizeComplexScript19);
            W.Text text9 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text9.Text = " ";

            run9.Append(runProperties9);
            run9.Append(text9);

            paragraph10.Append(paragraphProperties10);
            paragraph10.Append(run9);

            W.Paragraph paragraph11 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "2B4B8144", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties11 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId11 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties11 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts20 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold20 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript20 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties11.Append(runFonts20);
            paragraphMarkRunProperties11.Append(bold20);
            paragraphMarkRunProperties11.Append(fontSizeComplexScript20);

            paragraphProperties11.Append(paragraphStyleId11);
            paragraphProperties11.Append(paragraphMarkRunProperties11);

            W.Run run10 = new W.Run();

            W.RunProperties runProperties10 = new W.RunProperties();
            W.RunFonts runFonts21 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold21 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript21 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties10.Append(runFonts21);
            runProperties10.Append(bold21);
            runProperties10.Append(fontSizeComplexScript21);
            W.Text text10 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text10.Text = " ";

            run10.Append(runProperties10);
            run10.Append(text10);

            paragraph11.Append(paragraphProperties11);
            paragraph11.Append(run10);

            W.Paragraph paragraph12 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "0AAAC9A6", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties12 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId12 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties12 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts22 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold22 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript22 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties12.Append(runFonts22);
            paragraphMarkRunProperties12.Append(bold22);
            paragraphMarkRunProperties12.Append(fontSizeComplexScript22);

            paragraphProperties12.Append(paragraphStyleId12);
            paragraphProperties12.Append(paragraphMarkRunProperties12);

            W.Run run11 = new W.Run();

            W.RunProperties runProperties11 = new W.RunProperties();
            W.RunFonts runFonts23 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold23 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript23 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties11.Append(runFonts23);
            runProperties11.Append(bold23);
            runProperties11.Append(fontSizeComplexScript23);
            W.Text text11 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text11.Text = " ";

            run11.Append(runProperties11);
            run11.Append(text11);

            paragraph12.Append(paragraphProperties12);
            paragraph12.Append(run11);

            W.Paragraph paragraph13 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "5506A4C5", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties13 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId13 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties13 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts24 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold24 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript24 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties13.Append(runFonts24);
            paragraphMarkRunProperties13.Append(bold24);
            paragraphMarkRunProperties13.Append(fontSizeComplexScript24);

            paragraphProperties13.Append(paragraphStyleId13);
            paragraphProperties13.Append(paragraphMarkRunProperties13);

            W.Run run12 = new W.Run();

            W.RunProperties runProperties12 = new W.RunProperties();
            W.RunFonts runFonts25 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold25 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript25 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties12.Append(runFonts25);
            runProperties12.Append(bold25);
            runProperties12.Append(fontSizeComplexScript25);
            W.Text text12 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text12.Text = " ";

            run12.Append(runProperties12);
            run12.Append(text12);

            paragraph13.Append(paragraphProperties13);
            paragraph13.Append(run12);

            W.Paragraph paragraph14 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "7AEBEDA2", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties14 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId14 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties14 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts26 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold26 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript26 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties14.Append(runFonts26);
            paragraphMarkRunProperties14.Append(bold26);
            paragraphMarkRunProperties14.Append(fontSizeComplexScript26);

            paragraphProperties14.Append(paragraphStyleId14);
            paragraphProperties14.Append(paragraphMarkRunProperties14);

            W.Run run13 = new W.Run();

            W.RunProperties runProperties13 = new W.RunProperties();
            W.RunFonts runFonts27 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold27 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript27 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties13.Append(runFonts27);
            runProperties13.Append(bold27);
            runProperties13.Append(fontSizeComplexScript27);
            W.Text text13 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text13.Text = " ";

            run13.Append(runProperties13);
            run13.Append(text13);

            paragraph14.Append(paragraphProperties14);
            paragraph14.Append(run13);

            W.Paragraph paragraph15 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "48085869", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties15 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId15 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties15 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts28 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold28 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript28 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties15.Append(runFonts28);
            paragraphMarkRunProperties15.Append(bold28);
            paragraphMarkRunProperties15.Append(fontSizeComplexScript28);

            paragraphProperties15.Append(paragraphStyleId15);
            paragraphProperties15.Append(paragraphMarkRunProperties15);

            paragraph15.Append(paragraphProperties15);

            W.Paragraph paragraph16 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "03349807", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties16 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId16 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties16 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts29 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold29 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript29 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties16.Append(runFonts29);
            paragraphMarkRunProperties16.Append(bold29);
            paragraphMarkRunProperties16.Append(fontSizeComplexScript29);

            paragraphProperties16.Append(paragraphStyleId16);
            paragraphProperties16.Append(paragraphMarkRunProperties16);

            W.Run run14 = new W.Run();

            W.RunProperties runProperties14 = new W.RunProperties();
            W.RunFonts runFonts30 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold30 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript30 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties14.Append(runFonts30);
            runProperties14.Append(bold30);
            runProperties14.Append(fontSizeComplexScript30);
            W.Text text14 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text14.Text = " ";

            run14.Append(runProperties14);
            run14.Append(text14);

            paragraph16.Append(paragraphProperties16);
            paragraph16.Append(run14);

            W.Paragraph paragraph17 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "13B8FCE4", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties17 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId17 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties17 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts31 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold31 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript31 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties17.Append(runFonts31);
            paragraphMarkRunProperties17.Append(bold31);
            paragraphMarkRunProperties17.Append(fontSizeComplexScript31);

            paragraphProperties17.Append(paragraphStyleId17);
            paragraphProperties17.Append(paragraphMarkRunProperties17);

            paragraph17.Append(paragraphProperties17);

            W.Paragraph paragraph18 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3ACA8116", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties18 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId18 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties18 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts32 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold32 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript32 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties18.Append(runFonts32);
            paragraphMarkRunProperties18.Append(bold32);
            paragraphMarkRunProperties18.Append(fontSizeComplexScript32);

            paragraphProperties18.Append(paragraphStyleId18);
            paragraphProperties18.Append(paragraphMarkRunProperties18);

            W.Run run15 = new W.Run();

            W.RunProperties runProperties15 = new W.RunProperties();
            W.RunFonts runFonts33 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold33 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript33 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties15.Append(runFonts33);
            runProperties15.Append(bold33);
            runProperties15.Append(fontSizeComplexScript33);
            W.Text text15 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text15.Text = " ";

            run15.Append(runProperties15);
            run15.Append(text15);

            paragraph18.Append(paragraphProperties18);
            paragraph18.Append(run15);

            W.Paragraph paragraph19 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "05C6F3B3", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties19 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId19 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties19 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts34 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold34 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript34 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties19.Append(runFonts34);
            paragraphMarkRunProperties19.Append(bold34);
            paragraphMarkRunProperties19.Append(fontSizeComplexScript34);

            paragraphProperties19.Append(paragraphStyleId19);
            paragraphProperties19.Append(paragraphMarkRunProperties19);

            W.Run run16 = new W.Run();

            W.RunProperties runProperties16 = new W.RunProperties();
            W.RunFonts runFonts35 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold35 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript35 = new W.FontSizeComplexScript() { Val = "20" };

            runProperties16.Append(runFonts35);
            runProperties16.Append(bold35);
            runProperties16.Append(fontSizeComplexScript35);
            W.Text text16 = new W.Text() { Space = SpaceProcessingModeValues.Preserve };
            text16.Text = " ";

            run16.Append(runProperties16);
            run16.Append(text16);

            paragraph19.Append(paragraphProperties19);
            paragraph19.Append(run16);

            W.Paragraph paragraph20 = new W.Paragraph() { RsidParagraphAddition = "00682DA0", RsidParagraphProperties = "00682DA0", RsidRunAdditionDefault = "00682DA0", ParagraphId = "3C7FD12D", TextId = "77777777" };

            W.ParagraphProperties paragraphProperties20 = new W.ParagraphProperties();
            W.ParagraphStyleId paragraphStyleId20 = new W.ParagraphStyleId() { Val = "BodyText" };

            W.ParagraphMarkRunProperties paragraphMarkRunProperties20 = new W.ParagraphMarkRunProperties();
            W.RunFonts runFonts36 = new W.RunFonts() { ComplexScript = "Calibri" };
            W.Bold bold36 = new W.Bold();
            W.FontSizeComplexScript fontSizeComplexScript36 = new W.FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties20.Append(runFonts36);
            paragraphMarkRunProperties20.Append(bold36);
            paragraphMarkRunProperties20.Append(fontSizeComplexScript36);

            paragraphProperties20.Append(paragraphStyleId20);
            paragraphProperties20.Append(paragraphMarkRunProperties20);

            paragraph20.Append(paragraphProperties20);

            textBoxContent1.Append(paragraph1);
            textBoxContent1.Append(paragraph2);
            textBoxContent1.Append(paragraph3);
            textBoxContent1.Append(paragraph4);
            textBoxContent1.Append(paragraph5);
            textBoxContent1.Append(paragraph6);
            textBoxContent1.Append(paragraph7);
            textBoxContent1.Append(paragraph8);
            textBoxContent1.Append(paragraph9);
            textBoxContent1.Append(paragraph10);
            textBoxContent1.Append(paragraph11);
            textBoxContent1.Append(paragraph12);
            textBoxContent1.Append(paragraph13);
            textBoxContent1.Append(paragraph14);
            textBoxContent1.Append(paragraph15);
            textBoxContent1.Append(paragraph16);
            textBoxContent1.Append(paragraph17);
            textBoxContent1.Append(paragraph18);
            textBoxContent1.Append(paragraph19);
            textBoxContent1.Append(paragraph20);

            textBoxInfo21.Append(textBoxContent1);

            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties() { Rotation = 0, Vertical = A.TextVerticalValues.Horizontal, Wrap = A.TextWrappingValues.Square, LeftInset = 0, TopInset = 0, RightInset = 0, BottomInset = 0, Anchor = A.TextAnchoringTypeValues.Top, AnchorCenter = false, UpRight = true };
            A.NoAutoFit noAutoFit1 = new A.NoAutoFit();

            textBodyProperties1.Append(noAutoFit1);

            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(textBoxInfo21);
            wordprocessingShape1.Append(textBodyProperties1);

            graphicData1.Append(wordprocessingShape1);

            graphic1.Append(graphicData1);

            Wp14.RelativeWidth relativeWidth1 = new Wp14.RelativeWidth() { ObjectId = Wp14.SizeRelativeHorizontallyValues.Page };
            Wp14.PercentageWidth percentageWidth1 = new Wp14.PercentageWidth();
            percentageWidth1.Text = "0";

            relativeWidth1.Append(percentageWidth1);

            Wp14.RelativeHeight relativeHeight1 = new Wp14.RelativeHeight() { RelativeFrom = Wp14.SizeRelativeVerticallyValues.Page };
            Wp14.PercentageHeight percentageHeight1 = new Wp14.PercentageHeight();
            percentageHeight1.Text = "0";

            relativeHeight1.Append(percentageHeight1);

            anchor1.Append(simplePosition1);
            anchor1.Append(horizontalPosition1);
            anchor1.Append(verticalPosition1);
            anchor1.Append(extent1);
            anchor1.Append(effectExtent1);
            anchor1.Append(wrapNone1);
            anchor1.Append(docProperties1);
            anchor1.Append(nonVisualGraphicFrameDrawingProperties1);
            anchor1.Append(graphic1);
            anchor1.Append(relativeWidth1);
            anchor1.Append(relativeHeight1);

            drawing1.Append(anchor1);

            //alternateContentChoice1.Append(drawing1);
            //body.Append(alternateContentChoice1);
            //body.Append(drawing1);
            Run run = new Run();
            run.AppendChild(drawing1);

            body.Append(run);

        }


        private void SetAllNull()
        {
            this.Font = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
            this.Text = string.Empty;
        }

        internal void FromRun(Run r)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(r))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Text))
                    {
                        this.Text = ((Text)oxr.LoadCurrentElement()).Text;
                    }
                    else if (oxr.ElementType == typeof(RunFont))
                    {
                        RunFont rft = (RunFont)oxr.LoadCurrentElement();
                        if (rft.Val != null) this.Font.FontName = rft.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(RunPropertyCharSet))
                    {
                        RunPropertyCharSet rpcs = (RunPropertyCharSet)oxr.LoadCurrentElement();
                        if (rpcs.Val != null) this.Font.CharacterSet = rpcs.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontFamily))
                    {
                        FontFamily ff = (FontFamily)oxr.LoadCurrentElement();
                        if (ff.Val != null) this.Font.FontFamily = ff.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Bold))
                    {
                        Bold b = (Bold)oxr.LoadCurrentElement();
                        if (b.Val != null) this.Font.Bold = b.Val.Value;
                        else this.Font.Bold = true;
                    }
                    else if (oxr.ElementType == typeof(Italic))
                    {
                        Italic itlc = (Italic)oxr.LoadCurrentElement();
                        if (itlc.Val != null) this.Font.Italic = itlc.Val.Value;
                        else this.Font.Italic = true;
                    }
                    else if (oxr.ElementType == typeof(Strike))
                    {
                        Strike strk = (Strike)oxr.LoadCurrentElement();
                        if (strk.Val != null) this.Font.Strike = strk.Val.Value;
                        else this.Font.Strike = true;
                    }
                    else if (oxr.ElementType == typeof(Outline))
                    {
                        Outline outln = (Outline)oxr.LoadCurrentElement();
                        if (outln.Val != null) this.Font.Outline = outln.Val.Value;
                        else this.Font.Outline = true;
                    }
                    else if (oxr.ElementType == typeof(Shadow))
                    {
                        Shadow shdw = (Shadow)oxr.LoadCurrentElement();
                        if (shdw.Val != null) this.Font.Shadow = shdw.Val.Value;
                        else this.Font.Shadow = true;
                    }
                    else if (oxr.ElementType == typeof(Condense))
                    {
                        Condense cdns = (Condense)oxr.LoadCurrentElement();
                        if (cdns.Val != null) this.Font.Condense = cdns.Val.Value;
                        else this.Font.Condense = true;
                    }
                    else if (oxr.ElementType == typeof(Extend))
                    {
                        Extend ext = (Extend)oxr.LoadCurrentElement();
                        if (ext.Val != null) this.Font.Extend = ext.Val.Value;
                        else this.Font.Extend = true;
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Font.clrFontColor.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Font.HasFontColor = !this.Font.clrFontColor.IsEmpty();
                    }
                    else if (oxr.ElementType == typeof(FontSize))
                    {
                        FontSize ftsz = (FontSize)oxr.LoadCurrentElement();
                        if (ftsz.Val != null) this.Font.FontSize = ftsz.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(Underline))
                    {
                        Underline und = (Underline)oxr.LoadCurrentElement();
                        if (und.Val != null) this.Font.Underline = und.Val.Value;
                        else this.Font.Underline = UnderlineValues.Single;
                    }
                    else if (oxr.ElementType == typeof(VerticalTextAlignment))
                    {
                        VerticalTextAlignment vta = (VerticalTextAlignment)oxr.LoadCurrentElement();
                        if (vta.Val != null) this.Font.VerticalAlignment = vta.Val.Value;
                    }
                    else if (oxr.ElementType == typeof(FontScheme))
                    {
                        FontScheme ftsch = (FontScheme)oxr.LoadCurrentElement();
                        if (ftsch.Val != null) this.Font.FontScheme = ftsch.Val.Value;
                    }
                }
            }
        }

        internal Run ToRun()
        {
            Run r = new Run();
            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont() { Val = this.Font.FontName });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet() { Val = this.Font.CharacterSet.Value });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily() { Val = this.Font.FontFamily.Value });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize() { Val = this.Font.FontSize.Value });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline() { Val = this.Font.Underline });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment() { Val = this.Font.VerticalAlignment });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme() { Val = this.Font.FontScheme });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text)) r.Text.Space = SpaceProcessingModeValues.Preserve;

            return r;
        }

        /// <summary>
        /// Clone a new instance of SLRun.
        /// </summary>
        /// <returns>An SLRun object.</returns>
        public SLRun Clone()
        {
            SLRun r = new SLRun();
            r.Font = this.Font.Clone();
            r.Text = this.Text;

            return r;
        }

        [GenericTestCase(typeof(Bold), @"<b>Bold</b>")]
        [GenericTestCase(typeof(Bold), @"<strong>Strong</strong>")]
        [GenericTestCase(typeof(Italic), @"<i>Italic</i>")]
        [GenericTestCase(typeof(Italic), @"<em>Italic</em>")]
        [GenericTestCase(typeof(Strike), @"<s>Strike</s>")]
        [GenericTestCase(typeof(Strike), @"<strike>Strike</strike>")]
        [GenericTestCase(typeof(Strike), @"<del>Del</del>")]
        [GenericTestCase(typeof(Underline), @"<u>Underline</u>")]
        [GenericTestCase(typeof(Underline), @"<ins>Inserted</ins>")]
        public void ParseHtmlElements<T> (string html) where T : OpenXmlElement
        {
            ParsePhrasing<T>(html);
        }

        [TestCase(@"<sub>Subscript</sub>", VerticalPositionValues.Subscript)]
        [TestCase(@"<sup>Superscript</sup>", VerticalPositionValues.Superscript)]
        public void ParseSubSup (string html, VerticalPositionValues val)
        {
            var textAlign = ParsePhrasing<VerticalTextAlignment>(html);
            Assert.That(textAlign.Val.HasValue, Is.EqualTo(true));
            Assert.That(textAlign.Val.Value, Is.EqualTo(val));
        }

        [Test]
        public void ParseStyle ()
        {
            var elements = converter.Parse(@"<b style=""
font-style:italic;
font-size:12px;
color:red;
text-decoration:underline;
"">bold with italic style</b>");
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);
            Assert.Multiple(() => {
                Assert.IsTrue(runProperties.HasChild<Bold>());
                Assert.IsTrue(runProperties.HasChild<Italic>());
                Assert.IsTrue(runProperties.HasChild<FontSize>());
                Assert.IsTrue(runProperties.HasChild<Underline>());
                Assert.IsTrue(runProperties.HasChild<Color>());
            });
        }

        /*[Test]
        public void ParseDisruptiveStyle ()
        {
            //TODO:
            // italic should not be applied as we specify font-style=normal
            var elements = converter.Parse("<i style='font-style:normal'>Not italics</i>");
            Assert.Multiple(() => {
                var runProperties = elements[0].FirstChild.GetFirstChild<RunProperties>();
                Assert.IsNotNull(runProperties);
                Assert.IsTrue(!runProperties.HasChild<Italic>());
            });

            elements = converter.Parse("<span style='font-style:italic'><i style='font-style:normal'>Not italics</i></span>");
        }*/

        [TestCase(@"<q>Build a future where people live in harmony with nature.</q>", true)]
        [TestCase(@"<cite>Build a future where people live in harmony with nature.</cite>", false)]
        public void ParseQuote(string html, bool hasQuote)
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);
            if (hasQuote)
            {
                Assert.That(run.InnerText, Is.EqualTo(" " + converter.HtmlStyles.QuoteCharacters.Prefix));

                Run lastRun = elements[0].GetLastChild<Run>();
                Assert.IsNotNull(run);
                Assert.That(lastRun.InnerText, Is.EqualTo(converter.HtmlStyles.QuoteCharacters.Suffix));

                // focus the content run
                run = (Run) run.NextSibling();
            }

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var runStyle = runProperties.GetFirstChild<RunStyle>();
            Assert.IsNotNull(runStyle);
            Assert.That(runStyle.Val.Value, Is.EqualTo("QuoteChar"));
        }

        [Test]
        public void ParseBreak()
        {
            var elements = converter.Parse(@"Lorem<br/>Ipsum");
            Assert.That(elements.Count, Is.EqualTo(1));
            Assert.That(elements[0].ChildElements.Count, Is.EqualTo(3));

            Assert.That(elements[0].ChildElements[0], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[1], Is.InstanceOf(typeof(Run)));
            Assert.That(elements[0].ChildElements[2], Is.InstanceOf(typeof(Run)));
            Assert.IsNotNull(((Run)elements[0].ChildElements[1]).GetFirstChild<Break>());
        }

        private T ParsePhrasing<T> (string html) where T : OpenXmlElement
        {
            var elements = converter.Parse(html);
            Assert.That(elements.Count, Is.EqualTo(1));

            Run run = elements[0].GetFirstChild<Run>();
            Assert.IsNotNull(run);

            RunProperties runProperties = run.GetFirstChild<RunProperties>();
            Assert.IsNotNull(runProperties);

            var tag = runProperties.GetFirstChild<T>();
            Assert.IsNotNull(tag);
            return tag;
        }


        private void Initialize(string MajorFont, string MinorFont, List<System.Drawing.Color> ThemeColors, List<System.Drawing.Color> IndexedColors)
        {
            this.MajorFont = MajorFont;
            this.MinorFont = MinorFont;

            int i;
            this.listThemeColors = new List<System.Drawing.Color>();
            for (i = 0; i < ThemeColors.Count; ++i)
            {
                this.listThemeColors.Add(ThemeColors[i]);
            }

            this.listIndexedColors = new List<System.Drawing.Color>();
            for (i = 0; i < IndexedColors.Count; ++i)
            {
                this.listIndexedColors.Add(IndexedColors[i]);
            }

            istrReal = new InlineString();
        }

        /// <summary>
        /// Set the text. If text formatting is needed, use one of the AppendText() functions.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void SetText(string Text)
        {
            if (Text == null || Text.Length == 0)
            {
                this.istrReal.Text = null;
            }
            else
            {
                this.istrReal.Text = new Text();
                this.istrReal.Text.Text = Text;
                if (SLTool.ToPreserveSpace(Text))
                {
                    this.istrReal.Text.Space = SpaceProcessingModeValues.Preserve;
                }
            }
        }

        /// <summary>
        /// Get the text. This is the plain text string, and not the rich text runs.
        /// </summary>
        /// <returns>The plain text.</returns>
        public string GetText()
        {
            string result = string.Empty;
            if (this.istrReal.Text != null) result = this.istrReal.Text.Text;

            return result;
        }

        /// <summary>
        /// Get a list of rich text runs.
        /// </summary>
        /// <returns>A list of rich text runs.</returns>
        public List<SLRun> GetRuns()
        {
            List<SLRun> result = new List<SLRun>();
            SLRun r;

            using (OpenXmlReader oxr = OpenXmlReader.Create(this.istrReal))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Run))
                    {
                        r = new SLRun();
                        r.FromRun((Run)oxr.LoadCurrentElement());
                        result.Add(r.Clone());
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Replace the internal list of rich text runs.
        /// </summary>
        /// <param name="Runs">The new list of rich text runs for replacing.</param>
        public void ReplaceRuns(List<SLRun> Runs)
        {
            string sText = string.Empty;
            if (this.istrReal.Text != null) sText = this.istrReal.Text.Text;

            this.istrReal.RemoveAllChildren<Text>();
            this.istrReal.RemoveAllChildren<Run>();

            int i;
            // start from the end because we're prepending to the front
            for (i = Runs.Count - 1; i >= 0; --i)
            {
                this.istrReal.PrependChild<Run>(Runs[i].ToRun());
            }

            this.SetText(sText);
        }

        /// <summary>
        /// Append given text in the current theme's minor font and default font size.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void AppendText(string Text)
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);
            font.SetFont(FontSchemeValues.Minor, SLConstants.DefaultFontSize);

            this.AppendText(Text, font);
        }

        internal Run CreateRun(WordRun wordRun)
        {
            var run = new Run();
            var runProperties = new RunProperties();

            SetHyperlink(wordRun, runProperties);
            SetBold(wordRun, runProperties);
            SetItalic(wordRun, runProperties);
            SetUnderline(wordRun, runProperties);
            SetSize(wordRun, runProperties);
            SetColor(wordRun, runProperties);

            run.AppendChild(runProperties);

            SetBreak(wordRun, run);
            SetText(wordRun, run);

            return run;
        }

        private void SetColor(WordRun wordRun, RunProperties runProperties)
        {
            if (!string.IsNullOrEmpty(wordRun.FontColor))
            {
                try
                {
                    System.Drawing.Color color = System.Drawing.Color.FromName(wordRun.FontColor);
                    string colorHex = color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
                    Color wordColor = new Color() { Val = colorHex };
                    runProperties.AppendChild(wordColor);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }

        private static void SetBreak(WordRun wordRun, Run run)
        {
            if (wordRun.InsertLineBreak)
                run.AppendChild(new Break());
        }

        private static void SetText(WordRun wordRun, Run run)
        {
            if (string.IsNullOrEmpty(wordRun.Text))
                return;

            var text = new Text { Text = wordRun.Text };

            if (wordRun.InsertSpace)
                text.Space = SpaceProcessingModeValues.Preserve;

            run.AppendChild(text);
        }

        private static void SetSize(WordRun wordRun, RunProperties runProperties)
        {
            if (wordRun.Size != 0)
                runProperties.FontSize = new FontSize { Val = new StringValue((wordRun.Size * 2).ToString()) };
        }

        private static void SetUnderline(WordRun wordRun, RunProperties runProperties)
        {
            if (wordRun.Underline && string.IsNullOrEmpty(wordRun.Uri))
                AddUnderline(runProperties);
        }


        public Run GetRun(RunProperties runProperties)
        {
            var run = new Run {RunProperties = runProperties.CloneNode()};

            if (_config.Bold.HasValue)
            {
                run.RunProperties.Bold = new Bold {Val = OnOffValue.FromBoolean(_config.Bold.Value)};
            }

            if (_config.Italic.HasValue)
            {
                run.RunProperties.Italic = new Italic {Val = OnOffValue.FromBoolean(_config.Italic.Value)};
            }

            if (_config.Underline.HasValue)
            {
                run.RunProperties.Underline = new Underline {Val = _config.Underline};
            }

            if (_config.FontSize != null)
            {
                run.RunProperties.FontSize = new FontSize{Val = _config.FontSize};
            }

            if (!string.IsNullOrEmpty(this))
            {
                var lines = ((string) this).Split(new[] {"\r\n", "\n"}, StringSplitOptions.None).AsIndexed();

                foreach (var line in lines)
                {
                    if (!line.IsFirst)
                    {
                        run.AppendChild(new Break());
                    }

                    if (!string.IsNullOrEmpty(line.Value))
                    {
                        run.AppendChild(new Text(line) {Space = SpaceProcessingModeValues.Preserve});
                    }
                }
            }

            if (_config.Value == null)
            {
                run.AppendChild(new Break());
            }

            return run;
        }

DocumentFormat.OpenXml.Drawing.RunProperties : IEnumerable

Constructors :

public RunProperties()
public RunProperties(IEnumerable<OpenXmlElement> childElements = )
public RunProperties(OpenXmlElement[] childElements = )
public RunProperties(String outerXml = )

Methods :

public OpenXmlElement CloneNode(Boolean deep = )
public BooleanValue get_Kumimoji()
public Void set_Kumimoji(BooleanValue value = )
public StringValue get_Language()
public Void set_Language(StringValue value = )
public StringValue get_AlternativeLanguage()
public Void set_AlternativeLanguage(StringValue value = )
public Int32Value get_FontSize()
public Void set_FontSize(Int32Value value = )
public BooleanValue get_Bold()
public Void set_Bold(BooleanValue value = )
public BooleanValue get_Italic()
public Void set_Italic(BooleanValue value = )
public EnumValue<TextUnderlineValues> get_Underline()
public Void set_Underline(EnumValue<TextUnderlineValues> value = )
public EnumValue<TextStrikeValues> get_Strike()
public Void set_Strike(EnumValue<TextStrikeValues> value = )
public Int32Value get_Kerning()
public Void set_Kerning(Int32Value value = )
public EnumValue<TextCapsValues> get_Capital()
public Void set_Capital(EnumValue<TextCapsValues> value = )
public Int32Value get_Spacing()
public Void set_Spacing(Int32Value value = )
public BooleanValue get_NormalizeHeight()
public Void set_NormalizeHeight(BooleanValue value = )
public Int32Value get_Baseline()
public Void set_Baseline(Int32Value value = )
public BooleanValue get_NoProof()
public Void set_NoProof(BooleanValue value = )
public BooleanValue get_Dirty()
public Void set_Dirty(BooleanValue value = )
public BooleanValue get_SpellingError()
public Void set_SpellingError(BooleanValue value = )
public BooleanValue get_SmartTagClean()
public Void set_SmartTagClean(BooleanValue value = )
public UInt32Value get_SmartTagId()
public Void set_SmartTagId(UInt32Value value = )
public StringValue get_Bookmark()
public Void set_Bookmark(StringValue value = )
public Outline get_Outline()
public Void set_Outline(Outline value = )
public BooleanValue get_SmtClean()
public Void set_SmtClean(BooleanValue value = )
public UInt32Value get_SmtId()
public Void set_SmtId(UInt32Value value = )
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasChildren()
public String get_InnerText()
public Void set_InnerXml(String value = )
public Boolean AddChild(OpenXmlElement newChild = , Boolean throwOnError = True)
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T child = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerXml()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()