Ejemplo n.º 1
0
        private void BillingTotal(Table table, TotalRow total)
        {
            Row row = table.AddRow();

            row.Style = "TableRow";

            string font; Color shading;

            if (total.Inverse == true)
            {
                font    = "H2-9B-Inverse";
                shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);
            }
            else
            {
                font    = "H2-9B";
                shading = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);
            }

            Cell cell = row.Cells[Invoice.HasDiscount ? COLUMN_DISCOUNT : COLUMN_UNITPRICE];

            cell.Shading.Color = shading;
            cell.AddParagraph(total.Name, ParagraphAlignment.Left, font);

            cell = row.Cells[COLUMN_TOTAL];
            cell.Shading.Color = shading;
            cell.AddParagraph(total.Value.ToCurrency(Invoice.Currency), ParagraphAlignment.Right, font);
        }
Ejemplo n.º 2
0
        private void BillingTotal(Table table, TotalRow total)
        {
            Row row = table.AddRow();

            row.Style = "TableRow";

            string font; Color shading;

            if (total.Inverse == true)
            {
                font    = "H2-9B-Inverse";
                shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);
            }
            else
            {
                font    = "H2-9B";
                shading = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);
            }

            var cell = row.Cells[2];

            cell.Shading.Color = shading;
            cell.AddParagraph(total.Name, ParagraphAlignment.Left, font);

            cell = row.Cells[3];
            cell.Shading.Color = shading;
            if (!total.NegativeAmount)
            {
                cell.AddParagraph(total.Value.ToCurrency(Invoice.Currency), ParagraphAlignment.Right, font);
            }
            else
            {
                cell.AddParagraph("- " + total.Value.ToCurrency(Invoice.Currency), ParagraphAlignment.Right, font);
            }
        }
Ejemplo n.º 3
0
        private void PaymentSection()
        {
            Section section = Pdf.LastSection;

            Table table = section.AddTable();

            table.AddColumn(Unit.FromPoint(section.Document.PageWidth()));
            Row row = table.AddRow();

            if (Invoice.Details != null && Invoice.Details.Count > 0)
            {
                foreach (DetailRow detail in Invoice.Details)
                {
                    row.Cells[0].AddParagraph(detail.Title, ParagraphAlignment.Left, "H2-9B-Color");
                    row.Cells[0].Borders.Bottom = BorderLine;

                    row = table.AddRow();
                    TextFrame frame = null;
                    foreach (string line in detail.Paragraphs)
                    {
                        if (line == detail.Paragraphs[0])
                        {
                            frame       = row.Cells[0].AddTextFrame();
                            frame.Width = section.Document.PageWidth();
                        }
                        frame.AddParagraph(line, ParagraphAlignment.Left, "H2-9");
                    }
                }
            }

            if (Invoice.Company.HasCompanyNumber || Invoice.Company.HasVatNumber)
            {
                row = table.AddRow();

                Color shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);

                if (Invoice.Company.HasCompanyNumber && Invoice.Company.HasVatNumber)
                {
                    row.Cells[0].AddParagraph(string.Format("Company Number: {0}, VAT Number: {1}",
                                                            Invoice.Company.CompanyNumber, Invoice.Company.VatNumber),
                                              ParagraphAlignment.Center, "H2-9B-Inverse")
                    .Format.Shading.Color = shading;
                }
                else
                {
                    if (Invoice.Company.HasCompanyNumber)
                    {
                        row.Cells[0].AddParagraph(string.Format("Company Number: {0}", Invoice.Company.CompanyNumber),
                                                  ParagraphAlignment.Center, "H2-9B-Inverse")
                        .Format.Shading.Color = shading;
                    }
                    else
                    {
                        row.Cells[0].AddParagraph(string.Format("VAT Number: {0}", Invoice.Company.VatNumber),
                                                  ParagraphAlignment.Center, "H2-9B-Inverse")
                        .Format.Shading.Color = shading;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void BillingTotal(Table table, TotalRow total)
        {
            table.Columns[4].Format.Alignment = ParagraphAlignment.Center;

            Row row = table.AddRow();

            row.Style = "TableRow";

            string font; Color shading;

            if (total.Inverse == true)
            {
                font    = "H2-9B-Inverse";
                shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);
            }
            else
            {
                font    = "H2-9B";
                shading = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);
            }

            Cell cell = row.Cells[3];

            cell.Shading.Color = shading;
            cell.AddParagraph(total.Name, ParagraphAlignment.Left, font);

            cell = row.Cells[4];
            cell.Shading.Color = shading;
            cell.AddParagraph(total.Value.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, font);
        }
Ejemplo n.º 5
0
        private void BillingRow(Table table, ItemRow item)
        {
            Row row = table.AddRow();

            row.Style         = "TableRow";
            row.Shading.Color = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);

            Cell cell = row.Cells[0];

            cell.AddParagraph(item.Name, ParagraphAlignment.Left, "H2-9B");

            cell = row.Cells[1];
            cell.AddParagraph(item.Brand, ParagraphAlignment.Left, "H2-9");

            cell = row.Cells[2];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Amount.ToCurrency(), ParagraphAlignment.Center, "H2-9");

            cell = row.Cells[3];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Price.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");

            cell = row.Cells[4];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");
        }
Ejemplo n.º 6
0
        private void DefineStyles()
        {
            MigraDoc.DocumentObjectModel.Style style = Pdf.Styles["Normal"];
            style.Font.Name = "Calibri";

            style           = Pdf.Styles.AddStyle("H1-20", "Normal");
            style.Font.Size = 20;
            style.Font.Bold = true;

            style            = Pdf.Styles.AddStyle("H1-20-Red", "H1-20");
            style.Font.Color = Colors.Red;

            style            = Pdf.Styles.AddStyle("H1-20-Green", "H1-20");
            style.Font.Color = Colors.Green;

            style           = Pdf.Styles.AddStyle("H2-8", "Normal");
            style.Font.Size = 8;

            style = Pdf.Styles.AddStyle("H2-8-Blue", "H2-8");
            style.ParagraphFormat.Font.Color = Colors.Blue;

            style           = Pdf.Styles.AddStyle("H2-8B", "H2-8");
            style.Font.Bold = true;

            style           = Pdf.Styles.AddStyle("H2-9", "Normal");
            style.Font.Size = 9;

            style            = Pdf.Styles.AddStyle("H2-9-Grey", "H2-9");
            style.Font.Color = Colors.Gray;

            style           = Pdf.Styles.AddStyle("H2-9B", "H2-9");
            style.Font.Bold = true;

            style = Pdf.Styles.AddStyle("H2-9B-Inverse", "H2-9B");
            style.ParagraphFormat.Font.Color = Colors.White;

            style            = Pdf.Styles.AddStyle("H2-9B-Color", "H2-9B");
            style.Font.Color = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);

            style           = Pdf.Styles.AddStyle("H2-10", "Normal");
            style.Font.Size = 10;

            style            = Pdf.Styles.AddStyle("H2-10-Red", "H2-10");
            style.Font.Color = Colors.Red;

            style           = Pdf.Styles.AddStyle("H2-10B", "H2-10");
            style.Font.Bold = true;

            style            = Pdf.Styles.AddStyle("H2-10B-Color", "H2-10B");
            style.Font.Color = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);
        }
Ejemplo n.º 7
0
        private void PaymentSection()
        {
            Section section = Pdf.LastSection;

            Table table = section.AddTable();

            table.AddColumn(Unit.FromPoint(section.Document.PageWidth()));
            Row row = table.AddRow();

            if (Invoice.Details != null && Invoice.Details.Count > 0)
            {
                foreach (DetailRow detail in Invoice.Details)
                {
                    row.Cells[0].AddParagraph(detail.Title, ParagraphAlignment.Left, "H2-9B-Color");
                    row.Cells[0].Borders.Bottom = BorderLine;

                    row = table.AddRow();
                    TextFrame frame = null;
                    foreach (string line in detail.Paragraphs)
                    {
                        //if (line == detail.Paragraphs[0])
                        //{
                        //    frame = row.Cells[0].AddTextFrame();
                        //    frame.Width = section.Document.PageWidth();
                        //}
                        //frame.AddParagraph("X - " + line, ParagraphAlignment.Left, "H2-9");
                        Paragraph name = row.Cells[0].AddParagraph();
                        name.AddFormattedText(line, "H2-9-Grey");
                    }
                }
            }

            if (Invoice.Company.HasLegalTextLines)
            {
                row = table.AddRow();

                Color shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);

                foreach (var line in Invoice.Company.LegalTextLines)
                {
                    row.Cells[0].AddParagraph(line, ParagraphAlignment.Center, "H2-9B-Inverse")
                    .Format.Shading.Color = shading;
                }
            }
        }
Ejemplo n.º 8
0
        private void BillingRow(Table table, ItemRow item)
        {
            Row row = table.AddRow();

            row.Style         = "TableRow";
            row.Shading.Color = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);

            Cell cell = row.Cells[COLUMN_PRODUCT];

            cell.AddParagraph(item.Name, ParagraphAlignment.Left, "H2-9B");
            if (!String.IsNullOrEmpty(item.Description))
            {
                cell.AddParagraph(item.Description, ParagraphAlignment.Left, "H2-9-Grey");
            }

            cell = row.Cells[COLUMN_QTY];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Quantity.ToCurrency(), ParagraphAlignment.Right, "H2-9");

            cell = row.Cells[COLUMN_UNITPRICE];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Price.ToCurrency(Invoice.Currency), ParagraphAlignment.Right, "H2-9");

            cell = row.Cells[COLUMN_TOTAL];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Right, "H2-9");

            if (Invoice.Company.HasVatNumber)
            {
                cell = row.Cells[COLUMN_VATPERCENT];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(item.VAT.ToCurrency(), ParagraphAlignment.Right, "H2-9");
            }

            if (Invoice.HasDiscount)
            {
                cell = row.Cells[COLUMN_DISCOUNT];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(item.Discount, ParagraphAlignment.Right, "H2-9");
            }
        }
Ejemplo n.º 9
0
        private void HeaderSection()
        {
            HeaderFooter header = Pdf.LastSection.Headers.Primary;

            Table  table      = header.AddTable();
            double thirdWidth = MigraDocHelpers.PageWidth((Document)Pdf) / 3;

            table.AddColumn(ParagraphAlignment.Left, thirdWidth * 2);
            table.AddColumn();

            Row row = table.AddRow();

            if (!string.IsNullOrEmpty(Invoice.Image))
            {
                Image image = row.Cells[0].AddImage(Invoice.Image);
                row.Cells[0].VerticalAlignment = VerticalAlignment.Center;

                image.Height = Invoice.ImageSize.Height;
                image.Width  = Invoice.ImageSize.Width;
            }

            TextFrame frame = row.Cells[1].AddTextFrame();

            Table subTable = frame.AddTable();

            subTable.AddColumn(thirdWidth / 2);
            subTable.AddColumn(thirdWidth / 2);

            row = subTable.AddRow();
            row.Cells[0].MergeRight = 1;
            row.Cells[0].AddParagraph(Invoice.Title, ParagraphAlignment.Right, "H1-20");

            row = subTable.AddRow();
            row.Cells[0].AddParagraph("REFERENCE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.Reference, ParagraphAlignment.Right, "H2-9");
            row.Cells[0].AddParagraph("BILLING DATE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.BillingDate.ToShortDateString(), ParagraphAlignment.Right, "H2-9");
            row.Cells[0].AddParagraph("DUE DATE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.DueDate.ToShortDateString(), ParagraphAlignment.Right, "H2-9");
        }
Ejemplo n.º 10
0
        private void BillingRow(Table table, ItemRow item)
        {
            //Row row = table.AddRow();
            //row.Style = "TableRow";
            //row.Shading.Color = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);

            //Cell cell = row.Cells[0];
            //cell.AddParagraph(item.Name, ParagraphAlignment.Left, "H2-9B");
            //cell.AddParagraph(item.Description, ParagraphAlignment.Left, "H2-9-Grey");

            //cell = row.Cells[1];
            //cell.VerticalAlignment = VerticalAlignment.Center;
            //cell.AddParagraph(item.Amount.ToCurrency(), ParagraphAlignment.Center, "H2-9");

            //cell = row.Cells[2];
            //cell.VerticalAlignment = VerticalAlignment.Center;
            //cell.AddParagraph(item.VAT.ToCurrency(), ParagraphAlignment.Center, "H2-9");

            //cell = row.Cells[3];
            //cell.VerticalAlignment = VerticalAlignment.Center;
            //cell.AddParagraph(item.Price.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");

            //if (Invoice.HasDiscount)
            //{
            //    cell = row.Cells[4];
            //    cell.VerticalAlignment = VerticalAlignment.Center;
            //    cell.AddParagraph(item.Discount, ParagraphAlignment.Center, "H2-9");

            //    cell = row.Cells[5];
            //    cell.VerticalAlignment = VerticalAlignment.Center;
            //    cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");
            //}
            //else
            //{
            //    cell = row.Cells[4];
            //    cell.VerticalAlignment = VerticalAlignment.Center;
            //    cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");
            //}

            if (Invoice.Type == "Invoice")
            {
                Row row = table.AddRow();
                row.Style         = "TableRow";
                row.Shading.Color = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);

                Cell cell = row.Cells[0];
                cell.AddParagraph(item.Name, ParagraphAlignment.Left, "H2-9B");
                cell.AddParagraph(item.Description, ParagraphAlignment.Left, "H2-9-Grey");
            }
            else
            {
                Row row = table.AddRow();
                row.Style         = "TableRow";
                row.Shading.Color = MigraDocHelpers.BackColorFromHtml(Invoice.BackColor);

                Cell cell = row.Cells[0];
                cell.AddParagraph(item.Name, ParagraphAlignment.Left, "H2-9B");
                cell.AddParagraph(item.Description, ParagraphAlignment.Left, "H2-9-Grey");

                cell = row.Cells[1];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(item.Amount.ToCurrency(), ParagraphAlignment.Center, "H2-9");

                //cell = row.Cells[2];
                //cell.VerticalAlignment = VerticalAlignment.Center;
                //cell.AddParagraph(item.VAT.ToCurrency(), ParagraphAlignment.Center, "H2-9");

                cell = row.Cells[2];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(item.Price.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");

                cell = row.Cells[3];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");

                if (Invoice.HasDiscount)
                {
                    cell = row.Cells[3];
                    cell.VerticalAlignment = VerticalAlignment.Center;
                    cell.AddParagraph(item.Discount, ParagraphAlignment.Center, "H2-9");

                    cell = row.Cells[4];
                    cell.VerticalAlignment = VerticalAlignment.Center;
                    cell.AddParagraph(item.Total.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");
                }
                else
                {
                    cell = row.Cells[4];
                    cell.VerticalAlignment = VerticalAlignment.Center;
                    cell.AddParagraph(item.GCT.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");

                    var totalWithGCT = item.GCT + item.Total;

                    cell = row.Cells[5];
                    cell.VerticalAlignment = VerticalAlignment.Center;
                    cell.AddParagraph(totalWithGCT.ToCurrency(Invoice.Currency), ParagraphAlignment.Center, "H2-9");
                }
            }
        }