예제 #1
0
 internal static void FillFormattedParagraph(Paragraph par)
 {
     for (int idx = 0; idx <= 140; ++idx)
     {
         if (idx < 60)
         {
             FormattedText formText = par.AddFormattedText((idx).ToString(), TextFormat.Bold);
             formText.Font.Size = 16;
             formText.AddText(" ");
         }
         else if (idx < 100)
         {
             par.AddText((idx).ToString());
             par.AddText(" ");
         }
         else
         {
             FormattedText formText = par.AddFormattedText((idx).ToString(), TextFormat.Italic);
             formText.Font.Size = 6;
             formText.AddText(" ");
         }
         if (idx % 50 == 0)
         {
             par.AddLineBreak();
         }
     }
     par.AddText(" ...ready.");
 }
예제 #2
0
        /// <summary>
        /// Fills the section page with dynamic data.
        /// </summary>
        void PopulateSectionPage(int intSectionNumber)
        {
            // Iterate through each entry in the current section.
            for (int intEntryNumber = 0; intEntryNumber < _quote.sections[intSectionNumber]._materialTypes.Count; intEntryNumber++)
            {
                // Each item fills two rows.
                var row1 = _table.AddRow();
                var row2 = _table.AddRow();
                row1.TopPadding                 = 1.5;
                row1.Cells[0].Shading.Color     = TableGray;
                row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                row1.Cells[0].MergeDown         = 1;
                row1.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
                row1.Cells[1].MergeRight        = 3;

                row1.Cells[0].AddParagraph(_quote.sections[intSectionNumber]._quantity[intEntryNumber].ToString());
                var paragraph     = row1.Cells[1].AddParagraph();
                var formattedText = new FormattedText()
                {
                    Style = "Title"
                };
                formattedText.AddText(_quote.sections[intSectionNumber].materialTypes[intEntryNumber]);
                paragraph.Add(formattedText);

                // Fill all the columns with unit costs and true costs for each entry in the section page.
                // Relies on all section lists having synchronized entries.
                row2.Cells[1].AddParagraph($"{_quote.sections[intSectionNumber].labourUnitCosts[intEntryNumber].ToString("c")}/unit");
                row2.Cells[2].AddParagraph(_quote.sections[intSectionNumber].labourCosts[intEntryNumber].ToString("c"));
                row2.Cells[3].AddParagraph($"{_quote.sections[intSectionNumber].materialUnitCosts[intEntryNumber].ToString("c")}/unit");
                row2.Cells[4].AddParagraph(_quote.sections[intSectionNumber].materialCosts[intEntryNumber].ToString("c"));


                _table.SetEdge(0, _table.Rows.Count - 2, 5, 2, Edge.Box, BorderStyle.Single, 0.75);
            }


            // Add the labour total columns.
            var row = _table.AddRow();

            row.Cells[0].AddParagraph("Labour Total");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 1;
            row.Cells[2].AddParagraph(_quote.sections[intSectionNumber].totalLabourCost.ToString("c"));
            row.Cells[2].Format.Font.Name = "Segoe UI";

            // Add the material total columns.
            row.Cells[3].AddParagraph("Materials Total");
            row.Cells[3].Borders.Visible  = false;
            row.Cells[3].Format.Font.Bold = true;
            row.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].AddParagraph(_quote.sections[intSectionNumber].totalMaterialCost.ToString("c"));
            row.Cells[4].Format.Font.Name = "Segoe UI";

            // Set the borders of the specified cell range.
            _table.SetEdge(2, _table.Rows.Count - 1, 1, 1, Edge.Box, BorderStyle.Single, 0.75);
            _table.SetEdge(4, _table.Rows.Count - 1, 1, 1, Edge.Box, BorderStyle.Single, 0.75);
        }
예제 #3
0
파일: cPdf.cs 프로젝트: alfieri66/moneyBox
        public string pdfRapportoAgentePlus(string autore, string emailAutore, string periodoRiferimento, Single acconto, Single recupero, Single daRiportare, Single monete, Single carta, string targa, List <cCostanti.tOperazione> info)
        {
            cCostanti costanti = new cCostanti();
            string    testo = "";
            string    fileName, pathFileName;
            string    pageFooterText = "";

            DateTime  currentTime     = DateTime.Now;
            Document  document        = new Document();
            Table     table           = new MigraDoc.DocumentObjectModel.Tables.Table();
            Paragraph infoPremilinari = new MigraDoc.DocumentObjectModel.Paragraph();
            Column    colonna;

            FormattedText ftextTarga = new FormattedText();

            fileName     = ("pdf_" + emailAutore).Replace(" ", "").Replace(".", "_").Replace("@", "_") + ".pdf";
            pathFileName = HttpContext.Current.Server.MapPath(costanti.pathRemoto + "/" + fileName);

            Style style = document.Styles["Normal"];

            style.Font.Name = "Arial Unicode MS";
            style.Font.Size = 12;
            style.Font.Bold = false;


            //table Style
            style           = document.Styles.AddStyle("tabella", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = false;

            style           = document.Styles.AddStyle("rigaBold", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = true;

            style           = document.Styles.AddStyle("riga24", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 24;
            style.Font.Bold = true;

            style           = document.Styles.AddStyle("testoBold", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = true;

            style            = document.Styles.AddStyle("testoRosso", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.OrangeRed;

            style            = document.Styles.AddStyle("testoBlu", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.DarkBlue;

            style            = document.Styles.AddStyle("testoLightBlu", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 12;
            style.Font.Bold  = false;
            style.Font.Color = Colors.DarkBlue;

            style            = document.Styles.AddStyle("testoNero", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.Black;

            style            = document.Styles.AddStyle("Titolo", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 16;
            style.Font.Bold  = true;
            style.Font.Color = Colors.Orange;

            Section page = document.AddSection();

            //header
            Paragraph header = page.Headers.Primary.AddParagraph();

            header.AddText("Money BOX");
            header.Format.Alignment = ParagraphAlignment.Left;
            header.Style            = "Titolo";
            testo  = string.Format("{0}, {1}, targa: ", autore, emailAutore);
            header = page.Headers.Primary.AddParagraph();
            header.AddText(testo);
            ftextTarga.AddText(targa.ToUpper());
            ftextTarga.Color = Colors.Red;
            header.Add(ftextTarga);
            header.AddText("\n");
            header.Format.Alignment = ParagraphAlignment.Left;

            //footer
            pageFooterText = string.Format(" report del {0} ", currentTime.ToShortDateString()) + "\n";
            Paragraph footer = page.Footers.Primary.AddParagraph();

            footer.AddText(pageFooterText);
            footer.Format.Alignment = ParagraphAlignment.Center;

            table.Style               = "tabella";
            table.Borders.Color       = Colors.Black;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 0;

            colonna = table.AddColumn("6cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;

            infoPremilinari.AddText("\nPeriodo di riferimento: ");
            infoPremilinari.AddFormattedText(periodoRiferimento, TextFormat.Bold);
            infoPremilinari.AddText("\n\n");


            page.Add(infoPremilinari);
            Row riga = table.AddRow();

            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Locale");
            riga.Cells[1].AddParagraph("acconto");
            riga.Cells[2].AddParagraph("recupero \n da riportare");
            riga.Cells[3].AddParagraph("da Riportare");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;

            foreach (var value in info)
            {
                riga = table.AddRow();
                int position = value.data.IndexOf(" ");

                if (value.acconto == 0 && value.recupero == 0 && value.daRiportare == 0)
                {
                    riga.Cells[0].AddParagraph(value.nomeLocale + "\n" + value.data.Substring(0, position));
                    riga.Cells[0].Style = "testoLightBlu";
                    riga.Cells[1].AddParagraph("*** OPERAZIONE GENERICA ***");
                    riga.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                    riga.Cells[1].MergeRight       = 2;
                }
                else
                {
                    riga.Cells[0].AddParagraph(value.nomeLocale + "\n" + value.data.Substring(0, position));
                    if (value.acconto == 0)
                    {
                        riga.Cells[1].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[1].AddParagraph(String.Format("{0:0,0.00}", value.acconto));
                    }

                    if (value.recupero == 0)
                    {
                        riga.Cells[2].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", value.recupero));
                    }
                    if (value.daRiportare == 0)
                    {
                        riga.Cells[3].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[3].AddParagraph(String.Format("{0:0,0.00}", value.daRiportare));
                    }
                    riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                    riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
                    riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
                    riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
                }
            }

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nFlusso acconti\n\n");
            riga.Cells[1].AddParagraph("\n" + String.Format("{0:0,0.00}", acconto));
            riga.Cells[2].AddParagraph("");
            riga.Cells[2].MergeRight       = 1;
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[1].Style            = "testoBlu";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Flusso di cassa");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", recupero));
            riga.Cells[3].AddParagraph(String.Format("{0:0,0.00}", daRiportare));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;


            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Monete");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", monete));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].MergeDown        = 3;

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Carta");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", carta));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Tot. cassa");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", monete + carta + recupero));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoNero";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nFlusso di cassa\n\n");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph("\n" + String.Format("{0:0,0.00}", monete + carta + recupero - daRiportare));
            riga.Cells[3].AddParagraph("\n");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoRosso";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nCassa Generale\n\n");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph("\n" + String.Format("{0:0,0.00}", acconto + monete + carta + recupero - daRiportare));
            riga.Cells[3].AddParagraph("\n");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoNero";

            page.Add(table);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            pdfRenderer.PdfDocument.Save(pathFileName);

            //Process.Start(fileName);
            return(fileName);
        }
예제 #4
0
        /// <summary>
        /// Creates the dynamic parts of the invoice.
        /// </summary>
        void FillContent()
        {
            const double vat = 0.07;
            double       totalExtendedPrice = 0;

            // Iterate the invoice items.
            foreach (var expense in expenses)
            {
                var row1 = this._table.AddRow();
                row1.TopPadding                 = 1.5;
                row1.Cells[0].Shading.Color     = TableGray;
                row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                row1.Cells[1].Shading.Color     = TableGray;

                var paragraph     = row1.Cells[0].AddParagraph();
                var formattedText = new FormattedText()
                {
                    Style = "Title"
                };
                formattedText.AddText(expense.Description);
                paragraph.Add(formattedText);
                row1.Cells[1].AddParagraph(expense.Cost.ToString("0.00"));
                totalExtendedPrice += expense.Cost;

                _table.SetEdge(0, _table.Rows.Count - 2, 1, 2, Edge.Box, BorderStyle.Single, 0.75);
            }

            // Add an invisible row as a space line to the table.
            var row = _table.AddRow();

            row.Borders.Visible = false;

            // Add the total price row.
            row = _table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("Total");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].AddParagraph(totalExtendedPrice.ToString("0.00") + " €");
            row.Cells[1].Format.Font.Name = "Segoe UI";

            //// Add the VAT row.
            //row = _table.AddRow();
            //row.Cells[0].Borders.Visible = false;
            //row.Cells[0].AddParagraph("VAT (" + (vat * 100) + "%)");
            //row.Cells[0].Format.Font.Bold = true;
            //row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //row.Cells[0].MergeRight = 4;
            //row.Cells[1].AddParagraph((vat * totalExtendedPrice).ToString("0.00") + " €");

            //// Add the total due row.
            //row = _table.AddRow();
            //row.Cells[0].AddParagraph("Total Due");
            //row.Cells[0].Borders.Visible = false;
            //row.Cells[0].Format.Font.Bold = true;
            //row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //row.Cells[0].MergeRight = 4;
            //totalExtendedPrice += vat * totalExtendedPrice;
            //row.Cells[1].AddParagraph(totalExtendedPrice.ToString("0.00") + " €");
            //row.Cells[1].Format.Font.Name = "Segoe UI";
            //row.Cells[1].Format.Font.Bold = true;

            //// Set the borders of the specified cell range.
            //_table.SetEdge(1, _table.Rows.Count - 4, 1, 1, Edge.Box, BorderStyle.Single, 0.75);
        }
        /// <summary>
        /// Creates the dynamic parts of the invoice.
        /// </summary>
        void FillContent()
        {
            const double vat = 0.07;

            // Fill the address in the address text frame.
            var item      = SelectItem("/invoice/to");
            var paragraph = _addressFrame.AddParagraph();

            paragraph.AddText(GetValue(item, "name/singleName"));
            paragraph.AddLineBreak();
            paragraph.AddText(GetValue(item, "address/line1"));
            paragraph.AddLineBreak();
            paragraph.AddText(GetValue(item, "address/postalCode") + " " + GetValue(item, "address/city"));

            // Iterate the invoice items.
            double totalExtendedPrice = 0;
            var    iter = _navigator.Select("/invoice/items/*");

            while (iter.MoveNext())
            {
                item = iter.Current;
                var quantity = GetValueAsDouble(item, "quantity");
                var price    = GetValueAsDouble(item, "price");
                var discount = GetValueAsDouble(item, "discount");

                // Each item fills two rows.
                var row1 = this._table.AddRow();
                var row2 = this._table.AddRow();
                row1.TopPadding                 = 1.5;
                row1.Cells[0].Shading.Color     = TableGray;
                row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                row1.Cells[0].MergeDown         = 1;
                row1.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
                row1.Cells[1].MergeRight        = 3;
                row1.Cells[5].Shading.Color     = TableGray;
                row1.Cells[5].MergeDown         = 1;

                row1.Cells[0].AddParagraph(GetValue(item, "itemNumber"));
                paragraph = row1.Cells[1].AddParagraph();
                var formattedText = new FormattedText()
                {
                    Style = "Title"
                };
                formattedText.AddText(GetValue(item, "title"));
                paragraph.Add(formattedText);
                paragraph.AddFormattedText(" by ", TextFormat.Italic);
                paragraph.AddText(GetValue(item, "author"));
                row2.Cells[1].AddParagraph(GetValue(item, "quantity"));
                row2.Cells[2].AddParagraph(price.ToString("0.00") + " €");
                if (discount > 0)
                {
                    row2.Cells[3].AddParagraph(discount.ToString("0") + '%');
                }
                row2.Cells[4].AddParagraph();
                row2.Cells[5].AddParagraph(price.ToString("0.00"));
                var extendedPrice = quantity * price;
                extendedPrice = extendedPrice * (100 - discount) / 100;
                row1.Cells[5].AddParagraph(extendedPrice.ToString("0.00") + " €");
                row1.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
                totalExtendedPrice += extendedPrice;

                _table.SetEdge(0, _table.Rows.Count - 2, 6, 2, Edge.Box, BorderStyle.Single, 0.75);
            }

            // Add an invisible row as a space line to the table.
            var row = _table.AddRow();

            row.Borders.Visible = false;

            // Add the total price row.
            row = _table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("Total Price");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 4;
            row.Cells[5].AddParagraph(totalExtendedPrice.ToString("0.00") + " €");
            row.Cells[5].Format.Font.Name = "Segoe UI";

            // Add the VAT row.
            row = _table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("VAT (" + (vat * 100) + "%)");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 4;
            row.Cells[5].AddParagraph((vat * totalExtendedPrice).ToString("0.00") + " €");

            // Add the additional fee row.
            row = _table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("Shipping and Handling");
            row.Cells[5].AddParagraph(0.ToString("0.00") + " €");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 4;

            // Add the total due row.
            row = _table.AddRow();
            row.Cells[0].AddParagraph("Total Due");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 4;
            totalExtendedPrice           += vat * totalExtendedPrice;
            row.Cells[5].AddParagraph(totalExtendedPrice.ToString("0.00") + " €");
            row.Cells[5].Format.Font.Name = "Segoe UI";
            row.Cells[5].Format.Font.Bold = true;

            // Set the borders of the specified cell range.
            _table.SetEdge(5, _table.Rows.Count - 4, 1, 4, Edge.Box, BorderStyle.Single, 0.75);

            // Add the notes paragraph.
            paragraph = _document.LastSection.AddParagraph();
            paragraph.Format.Alignment        = ParagraphAlignment.Center;
            paragraph.Format.SpaceBefore      = "1cm";
            paragraph.Format.Borders.Width    = 0.75;
            paragraph.Format.Borders.Distance = 3;
            paragraph.Format.Borders.Color    = TableBorder;
            paragraph.Format.Shading.Color    = TableGray;
            item = SelectItem("/invoice");
            paragraph.AddText(GetValue(item, "notes"));
        }
예제 #6
0
        /// <summary>
        /// Fills the summary page with data from the quote object.
        /// </summary>
        void PopulateSummaryPage()
        {
            // Fill the quote title in the text frame.
            var paragraph = _quoteName.AddParagraph();

            paragraph.AddText(_quote.title);

            // Create a counter for number of sections.
            int intSectionNumber = 0;

            // Iterate through the test data and transfer data to table.
            foreach (Section section in _quote.sections)
            {
                // Increment the section number.
                intSectionNumber++;

                // Each item fills two rows.
                var row1 = _table.AddRow();
                var row2 = _table.AddRow();
                row1.TopPadding                 = 1.5;
                row1.Cells[0].Shading.Color     = TableGray;
                row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                row1.Cells[0].MergeDown         = 1;
                row1.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
                row1.Cells[1].MergeRight        = 2;
                row1.Cells[4].Shading.Color     = TableGray;
                row1.Cells[4].MergeDown         = 1;

                row1.Cells[0].AddParagraph(intSectionNumber.ToString());
                paragraph = row1.Cells[1].AddParagraph();
                var formattedText = new FormattedText()
                {
                    Style = "Title"
                };
                formattedText.AddText(section.title);
                paragraph.Add(formattedText);

                row2.Cells[1].AddParagraph($"{section.totalLabourHours.ToString()} hrs");
                row2.Cells[2].AddParagraph($"{section.totalLabourCost.ToString("c")}");
                row2.Cells[3].AddParagraph($"{section.totalMaterialCost.ToString("c")}");


                row1.Cells[4].AddParagraph($"{section.totalCost.ToString("c")}");
                row1.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;

                _table.SetEdge(0, _table.Rows.Count - 2, 5, 2, Edge.Box, BorderStyle.Single, 0.75);
            }

            // Add an invisible row as a space line to the table.
            var row = _table.AddRow();

            row.Borders.Visible = false;

            // Add the total labour hours row.
            row = _table.AddRow();
            row.Cells[0].AddParagraph("Total Labour Hours");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 3;
            row.Cells[4].AddParagraph($"{_quote.totalLabourHours.ToString()}");
            row.Cells[4].Format.Font.Name = "Segoe UI";

            // Add the additional costs row.
            row = _table.AddRow();
            row.Cells[0].AddParagraph("Extra Costs");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 3;
            row.Cells[4].AddParagraph($"{_quote.extraCosts.ToString("c")}");
            row.Cells[4].Format.Font.Name = "Segoe UI";


            // Add the cost deductions row.
            row = _table.AddRow();
            row.Cells[0].AddParagraph("Cost Deductions");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 3;
            row.Cells[4].AddParagraph($"-({_quote.costDedeductions.ToString("c")})");
            row.Cells[4].Format.Font.Name = "Segoe UI";


            // Add the total cost row.
            row = _table.AddRow();
            row.Cells[0].AddParagraph("Total Cost");
            row.Cells[0].Borders.Visible  = false;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight       = 3;
            row.Cells[4].AddParagraph($"{_quote.totalCost.ToString("c")}");
            row.Cells[4].Format.Font.Name = "Segoe UI";
            row.Cells[4].Format.Font.Bold = true;

            // Set the borders of the specified cell range.
            _table.SetEdge(4, _table.Rows.Count - 4, 1, 4, Edge.Box, BorderStyle.Single, 0.75);

            // Add the comment box.
            paragraph = _document.LastSection.AddParagraph();
            paragraph.Format.Alignment        = ParagraphAlignment.Left;
            paragraph.Format.SpaceBefore      = "1cm";
            paragraph.Format.Borders.Width    = 0.75;
            paragraph.Format.Borders.Distance = 3;
            paragraph.Format.Borders.Color    = TableBorder;
            paragraph.Format.Shading.Color    = TableGray;
            paragraph.AddText("Comments\n\n\n"); // Creates a big box for additional comments.
        }