Add() публичный Метод

Adds a Paragraph, List, Table or another Section to this Section.
public Add ( Object o ) : bool
o Object an object of type Paragraph, List, Table or another Section
Результат bool
Пример #1
0
        public bool CreatePdf()
        {
            bool result = true;

            try
            {
                if (calendarEvent == null)
                {
                    result = false;
                }
                else
                {
                    PdfDocument.Open();
                    Chapter chapter = AddChapter(new Paragraph(GetTitleText("Záznam o návšteve"))
                    {
                        SpacingAfter = 10f, Alignment = HAlingmentLeft
                    }, 0, 0);
                    iTextSharp.text.Section firstSection = AddSection(chapter, 0f,
                                                                      new Paragraph(GetSectionText(calendarEvent.Patient.FullName + " " + calendarEvent.StartDate.ToString("d. MMMM yyyy, HH:mm")))
                                                                      , 0);

                    firstSection.Add(CreateInfoTable());

                    iTextSharp.text.Section actionsSection = AddSection(chapter, 0f, new Paragraph(GetSectionText("Vykonané")), 0);
                    if (!string.IsNullOrEmpty(calendarEvent.ExecutedActionText))
                    {
                        actionsSection.Add(new Paragraph(GetText(calendarEvent.ExecutedActionText)));
                    }
                    actionsSection.Add(CreateActionsTable());

                    iTextSharp.text.Section billingSection = AddSection(chapter, 0f, new Paragraph(GetSectionText("Vyúčtovanie")), 0);
                    EventBill eventBill = calendarEvent.EventBills.FirstOrDefault();
                    if (eventBill != null && eventBill.EventBillItems.Count != 0)
                    {
                        billingSection.Add(CreateBillingTable(eventBill));
                    }
                    else
                    {
                        billingSection.Add(new Paragraph(GetBoldText("Návšteva neobsahuje žiadne účtovné položky")));
                    }

                    PdfDocument.Add(chapter);

                    AddFooter();

                    PdfDocument.Close();
                }
            }
            catch (Exception ex)
            {
                BasicMessagesHandler.LogException(ex);
                result = false;
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Creates table with basic information about patient whome the budget belongs to
        /// </summary>
        private void AddInfoTable(iTextSharp.text.Section section)
        {
            try
            {
                PdfPTable table = new PdfPTable(2)
                {
                    HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f
                };

                PdfPCell cell = GetCell(System.Drawing.Color.White, GetBoldText("ID"));
                table.AddCell(cell);
                cell = GetCell(System.Drawing.Color.White, budget.ID.ToString());
                table.AddCell(cell);

                cell = GetCell(System.Drawing.Color.White, GetBoldText("Pacient"));
                table.AddCell(cell);
                cell = GetCell(System.Drawing.Color.White, budget.Patient.ToString());
                table.AddCell(cell);

                cell = GetCell(System.Drawing.Color.White, GetBoldText("Cena spolu"));
                table.AddCell(cell);
                cell = GetCell(System.Drawing.Color.White, budget.BudgetItems.Sum(x => (x.Count * x.UnitPrice)).ToString("0.00 €"));
                table.AddCell(cell);

                table.SpacingAfter = 10f;

                section.Add(table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        /// <summary>
        /// Creates table with information about budget items
        /// </summary>
        private void AddItemsTable(iTextSharp.text.Section section)
        {
            try
            {
                PdfPTable table = new PdfPTable(new[] { 60f, 20f, 20f })
                {
                    HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f, WidthPercentage = 100f
                };

                PdfPCell cell = new PdfPCell();

                bool firstRow = false;

                foreach (BudgetItem item in budget.BudgetItems)
                {
                    cell = GetCell(System.Drawing.Color.White, item.Name);
                    if (firstRow)
                    {
                        cell.UseVariableBorders = true;
                        cell.BorderColorTop     = BaseColor.BLACK;
                    }
                    table.AddCell(cell);

                    cell = GetCell(System.Drawing.Color.White, item.Count.ToString("0 ks"));
                    if (firstRow)
                    {
                        cell.UseVariableBorders = true;
                        cell.BorderColorTop     = BaseColor.BLACK;
                    }
                    table.AddCell(cell);

                    cell = GetCell(System.Drawing.Color.White, item.UnitPrice.ToString("0.00 €"));
                    if (firstRow)
                    {
                        cell.UseVariableBorders = true;
                        cell.BorderColorTop     = BaseColor.BLACK;
                    }
                    table.AddCell(cell);

                    firstRow = false;
                }

                table.SpacingAfter = 10f;

                section.Add(table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public bool CreatePdf()
        {
            bool result = true;

            try
            {
                if (patient == null || doctor == null)
                {
                    result = false;
                }
                else
                {
                    PdfDocument.Open();

                    Chapter chapter1 = AddChapter(
                        new Paragraph(GetTitleText(patient.FullName))
                    {
                        Alignment = HAlingmentCenter, SpacingAfter = 10f
                    },
                        0, 0);
                    iTextSharp.text.Section personalInfoSection = AddSection(chapter1, 0f, new Paragraph(GetSectionText("Osobné údaje")), 0);

                    PdfPTable table = new PdfPTable(new[] { 60f, 40f })
                    {
                        HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f, SpacingAfter = 10f, WidthPercentage = 100f
                    };

                    PdfPTable personalInfoTable = CreatePersonalInfoTable();
                    Image     pic = null;
                    if (patient.AvatarImagePath != null && System.IO.File.Exists(patient.AvatarImagePath))
                    {
                        pic = Image.GetInstance(patient.AvatarImagePath);
                        pic.ScaleToFit((RX - LX) / 2f, GetTableHeight(personalInfoTable));
                    }
                    else
                    {
                        pic = Image.GetInstance((System.Drawing.Image)Properties.Resources.noUserImage, System.Drawing.Imaging.ImageFormat.Png);
                    }

                    PdfPCell imageCell = new PdfPCell(pic, false)
                    {
                        PaddingTop = 5f, BorderColor = BaseColor.WHITE
                    };
                    PdfPCell tableCell = new PdfPCell(personalInfoTable)
                    {
                        PaddingTop = 5f, BorderColor = BaseColor.WHITE
                    };

                    table.AddCell(tableCell);
                    table.AddCell(imageCell);
                    personalInfoSection.Add(table);

                    iTextSharp.text.Section addressAndContactSection = AddSection(chapter1, 0f, new Paragraph(GetSectionText("Adresa a kontaktné údaje")), 0);
                    table = new PdfPTable(new[] { 100f })
                    {
                        HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f, WidthPercentage = 100f
                    };
                    PdfPCell addressCell = new PdfPCell(CreateAddressTable())
                    {
                        PaddingTop = 5f, BorderColor = BaseColor.WHITE
                    };
                    PdfPCell contactCell = new PdfPCell(CreateContactTable())
                    {
                        PaddingTop = 5f, BorderColor = BaseColor.WHITE
                    };
                    table.AddCell(addressCell);
                    table.AddCell(contactCell);
                    addressAndContactSection.Add(table);

                    Chapter chapter2 = AddChapter(
                        new Paragraph(GetTitleText("Zdravotná karta pacienta"))
                    {
                        SpacingAfter = 10f
                    },
                        0, 0);

                    foreach (var ezkoSection in ezkoController.GetSections().OrderBy(x => x.Name))
                    {
                        iTextSharp.text.Section pdfSection = AddSection(chapter2, 0f, new Paragraph(GetSectionText(ezkoSection.Name)), 0);
                        PdfPTable sectionTable             = CreateEzkoSectionTable(pdfSection, ezkoSection);
                        pdfSection.Add(sectionTable);
                    }

                    PdfDocument.Add(chapter1);
                    PdfDocument.Add(chapter2);

                    Chapter chapter3 = AddChapter(
                        new Paragraph(GetTitleText("Návštevy pacienta"))
                    {
                        SpacingAfter = 10f
                    },
                        0, 0);
                    if (patient.CalendarEvents.Count > 0)
                    {
                        PdfPTable eventsTable = CreateEventsTable();
                        chapter3.Add(eventsTable);
                    }
                    else
                    {
                        chapter3.Add(new Paragraph(GetNoteText("Pacient zatial nemá žiadne návštevy")));
                    }
                    //chapter3.Add(new Paragraph(GetText("Pacient zatial nemá žiadne návštevy")));

                    PdfDocument.Add(chapter3);
                    PdfDocument.Close();
                }
            }
            catch (Exception ex)
            {
                BasicMessagesHandler.LogException(ex);
                result = false;
            }

            return(result);
        }