A Section is a part of a Document containing other Sections, Paragraphs, List and/or Tables.
You can not construct a Section yourself. You will have to ask an instance of Section to the Chapter or Section to which you want to add the new Section.
Inheritance: System.Collections.ArrayList, ITextElementArray
Beispiel #1
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;
            }
        }
Beispiel #2
0
 /**
 * Creates a MarkedObject with a Section or Chapter object.
 * @param section   the marked section
 */
 public MarkedSection(Section section) : base() {
     if (section.Title != null) {
         title = new MarkedObject(section.Title);
         section.Title = null;
     }
     this.element = section;
 }
Beispiel #3
0
        //简单使用
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Document  document  = new Document();
            PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream("简单使用.pdf",
                                                                                 FileMode.OpenOrCreate));

            document.Open();

            PdfContentByte cb = pdfWriter.DirectContent; //最上方

            //画线
            cb.SetLineWidth(2);
            cb.MoveTo(0, 0);  //以当前页左下角为原点
            cb.LineTo(200, 300);

            cb.Stroke();

            //在某个具体位置绘制文本
            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252,
                                              BaseFont.NOT_EMBEDDED);

            cb.BeginText();
            cb.SetFontAndSize(bf, 12);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "This text is centered",
                               0, 100, 0);
            cb.EndText();

            //为了测试,添加3章
            for (int i = 0; i < 10; i++)
            {
                //章节的标题
                Paragraph cTitle = new Paragraph($"This is chapter {i}", FontFactory.GetFont(
                                                     FontFactory.COURIER, 18));
                Chapter chapter = new Chapter(cTitle, i);

                //如果是偶数章节书签默认不打开
                if (i % 2 == 0)
                {
                    chapter.BookmarkOpen = false;
                }

                //每章添加2个区域
                for (int j = 0; j < 60; j++)
                {
                    //子区域
                    Paragraph sTitle = new Paragraph($"This is section {j} in chapter {i}",
                                                     FontFactory.GetFont(FontFactory.COURIER, 12, BaseColor.BLUE));

                    Section section = chapter.AddSection(sTitle, 2);  //第二个参数表示树的深度
                }

                document.Add(chapter);
            }

            document.Close();
            Title = "简单使用";
        }
Beispiel #4
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);
        }
Beispiel #5
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;
            }
        }
Beispiel #6
0
        public bool CreatePdf()
        {
            bool result = true;

            try
            {
                if (budget == null)
                {
                    result = false;
                }
                else
                {
                    PdfDocument.Open();

                    Chapter chapter = AddChapter(new Paragraph(GetTitleText(budget.Name))
                    {
                        SpacingAfter = 10f, Alignment = HAlingmentLeft
                    }, 0, 0);

                    iTextSharp.text.Section infoSection = AddSection(chapter, 0f,
                                                                     new Paragraph(GetBoldText("Základné informácie"))
                    {
                        SpacingAfter = 0f, SpacingBefore = 0f
                    }, 0);
                    AddInfoTable(infoSection);

                    iTextSharp.text.Section itemsSection = AddSection(chapter, 0f,
                                                                      new Paragraph(GetBoldText("Položky"))
                    {
                        SpacingBefore = 0f, SpacingAfter = 0f
                    }, 0);
                    AddItemsTable(itemsSection);

                    PdfDocument.Add(chapter);

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

            return(result);
        }
Beispiel #7
0
        //1. 章节和区域(解决书签功能)
        //2 .章节之间默认会换页,就算前一章只占一行,当前章另起一页
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Document document = new Document();

            PdfWriter.GetInstance(document, new FileStream("章节和区域.pdf", FileMode.OpenOrCreate));
            document.Open();

            //添加10章
            for (int i = 0; i < 10; i++)
            {
                //章节的标题
                Paragraph cTitle = new Paragraph($"This is chapter {i}", FontFactory.GetFont(
                                                     FontFactory.COURIER, 18));
                Chapter chapter = new Chapter(cTitle, i);

                //如果是偶数章节书签默认不打开
                if (i % 2 == 0)
                {
                    chapter.BookmarkOpen = false;
                }

                //每章添加20个区域
                for (int j = 0; j < 60; j++)
                {
                    //子区域
                    Paragraph sTitle = new Paragraph($"This is section {j} in chapter {i}",
                                                     FontFactory.GetFont(FontFactory.COURIER, 12, BaseColor.BLUE));

                    Section section = chapter.AddSection(sTitle, 2);  //第二个参数表示树的深度
                }

                document.Add(chapter);
            }

            document.Close();
            Title = "章节和区域";
        }
Beispiel #8
0
 /// <summary>
 /// Adds a Section to this Section and returns it.
 /// </summary>
 /// <param name="indentation">the indentation of the new section</param>
 /// <param name="title">the title of the new section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(float indentation, string title)
 {
     Section section = new Section(new Paragraph(title), 1);
     section.Indentation = indentation;
     Add(section);
     return section;
 }
Beispiel #9
0
 /// <summary>
 /// Creates a Section, adds it to this Section and returns it.
 /// </summary>
 /// <param name="title">the title of the new section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(Paragraph title)
 {
     Section section = new Section(title, numberDepth + 1);
     Add(section);
     return section;
 }
Beispiel #10
0
 /// <summary>
 /// Creates a Section, adds it to this Section and returns it.
 /// </summary>
 /// <param name="indentation">the indentation of the new section</param>
 /// <param name="title">the title of the new section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(float indentation, Paragraph title)
 {
     Section section = new Section(title, 1);
     section.Indentation = indentation;
     Add(section);
     return section;
 }
Beispiel #11
0
 // methods that return a Section
 /// <summary>
 /// Creates a Section, adds it to this Section and returns it.
 /// </summary>
 /// <param name="indentation">the indentation of the new section</param>
 /// <param name="title">the title of the new section</param>
 /// <param name="numberDepth">the numberDepth of the section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(float indentation, Paragraph title, int numberDepth)
 {
     Section section = new Section(title, numberDepth);
     section.Indentation = indentation;
     Add(section);
     return section;
 }
Beispiel #12
0
 /**
  * Writes the HTML representation of a section.
  *
  * @param   section     the section to write
  * @param   indent      the indentation
  */
 protected void WriteSection(Section section, int indent)
 {
     if (section.Title != null) {
         int depth = section.Depth - 1;
         if (depth > 5) {
             depth = 5;
         }
         Properties styleAttributes = new Properties();
         if (section.Title.LeadingDefined) styleAttributes[Markup.CSS_KEY_LINEHEIGHT] = section.Title.Leading.ToString() + "pt";
         // start tag
         AddTabs(indent);
         WriteStart(HtmlTags.H[depth]);
         Write(section.Title.Font, styleAttributes);
         String alignment = HtmlEncoder.GetAlignment(section.Title.Alignment);
         if (!"".Equals(alignment)) {
             Write(HtmlTags.ALIGN, alignment);
         }
         WriteMarkupAttributes(markup);
         os.WriteByte(GT);
         currentfont.Push(section.Title.Font);
         // contents
         foreach (IElement i in section.Title) {
             Write(i, indent + 1);
         }
         // end tag
         AddTabs(indent);
         WriteEnd(HtmlTags.H[depth]);
         currentfont.Pop();
     }
     foreach (IElement i in section) {
         Write(i, indent);
     }
 }
Beispiel #13
0
     // methods that return a Section
 
     /// <summary>
     /// Creates a Section, adds it to this Section and returns it.
     /// </summary>
     /// <param name="indentation">the indentation of the new section</param>
     /// <param name="title">the title of the new section</param>
     /// <param name="numberDepth">the numberDepth of the section</param>
     /// <returns>the newly added Section</returns>
     public virtual Section AddSection(float indentation, Paragraph title, int numberDepth) {
         if (AddedCompletely) {
             throw new InvalidOperationException(MessageLocalization.GetComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
         }
         Section section = new Section(title, numberDepth);
         section.Indentation = indentation;
         Add(section);
         return section;
     }
Beispiel #14
0
        private PdfPTable CreateEzkoSectionTable(iTextSharp.text.Section pdfSection, DatabaseCommunicator.Model.Section ezkoSection)
        {
            PdfPTable table = new PdfPTable(3)
            {
                HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f, SpacingAfter = 10f
            };

            table.WidthPercentage = 100f;

            //PdfPCell cell = GetCell(System.Drawing.Color.White, " ");
            //cell.BorderWidthTop = 1f;
            //cell.UseVariableBorders = true;
            //cell.BorderColorTop = BaseColor.BLACK;
            //table.AddCell(cell);

            //cell = GetCell(System.Drawing.Color.White, GetBoldText("Zistené lekárom"));
            //cell.BorderWidthTop = 1f;
            //cell.UseVariableBorders = true;
            //cell.BorderColorTop = BaseColor.BLACK;
            //table.AddCell(cell);

            //cell = GetCell(System.Drawing.Color.White, GetBoldText("Odpoveď pacienta"));
            //cell.BorderWidthTop = 1f;
            //cell.UseVariableBorders = true;
            //cell.BorderColorTop = BaseColor.BLACK;
            //table.AddCell(cell);

            AddCell(table, " ", System.Drawing.Color.White);
            AddCell(table, GetBoldText("Zistené lekárom"), System.Drawing.Color.White);
            AddCell(table, GetBoldText("Odpoveď pacienta"), System.Drawing.Color.White);

            foreach (var field in ezkoSection.Fields)
            {
                AddCell(table, GetBoldText(field.Name), System.Drawing.Color.White);
                switch (field.TypeID)
                {
                case (int)FieldTypeEnum.Text:
                case (int)FieldTypeEnum.LongText:
                    string doctorsAnswer = field.FilledFields.Where(x => x.UserID == doctor.ID && x.PatientID == patient.ID).FirstOrDefault()?.FieldAnswer?.TextValue ?? "nevyplnené";
                    AddCell(table, GetText(doctorsAnswer), System.Drawing.Color.White);
                    string patientsAnswer = field.FilledFields.Where(x => x.UserID == null && x.PatientID == patient.ID).FirstOrDefault()?.FieldAnswer?.TextValue ?? "nevyplnené";
                    AddCell(table, GetText(patientsAnswer), System.Drawing.Color.White);
                    break;

                case (int)FieldTypeEnum.RadioBox:
                case (int)FieldTypeEnum.SelectBox:
                    doctorsAnswer = field.FilledFields.Where(x => x.UserID == doctor.ID && x.PatientID == patient.ID).FirstOrDefault()?.FieldValueAnswers.FirstOrDefault()?.FieldValue.Value ?? "nevyplnené";
                    AddCell(table, GetText(doctorsAnswer), System.Drawing.Color.White);
                    patientsAnswer = field.FilledFields.Where(x => x.UserID == null && x.PatientID == patient.ID).FirstOrDefault()?.FieldValueAnswers.FirstOrDefault()?.FieldValue.Value ?? "nevyplnené";
                    AddCell(table, GetText(patientsAnswer), System.Drawing.Color.White);
                    break;

                case (int)FieldTypeEnum.CheckBox:
                    doctorsAnswer = GetAnswers(field.FilledFields.Where(x => x.UserID == doctor.ID && x.PatientID == patient.ID).FirstOrDefault()?.FieldValueAnswers);
                    AddCell(table, GetText(doctorsAnswer), System.Drawing.Color.White);
                    patientsAnswer = GetAnswers(field.FilledFields.Where(x => x.UserID == null && x.PatientID == patient.ID).FirstOrDefault()?.FieldValueAnswers);
                    AddCell(table, GetText(patientsAnswer), System.Drawing.Color.White);
                    break;

                default:
                    break;
                }
            }

            return(table);
        }
        private void GenerateBatteryChartByCustVin(string TempFolderPath, string ProcessDate)
        {
            Paragraph para = new Paragraph();
            Section sec = new Section();
            string CustomerId = string.Empty;
            string CustomerName = string.Empty;
            string Vin = string.Empty;
            int VinId = 0;
            string Bus = string.Empty;

            DataTable dtCust = new DataTable();
            DataTable dtVin = new DataTable();
            GetData gd = new GetData();
            dtCust = gd.DtGetCustomerInfo(DateTime.Parse(ProcessDate));

            int i = 0;
            int j = 0;
            foreach (DataRow dRow in dtCust.Rows)
            {

                i++;
                j = 0;
                CustomerId = dRow["CustomerId"].ToString();
                CustomerName = dRow["CustomerName"].ToString();

                dtVin = gd.DtGetCustomerVehicleInfo(int.Parse(CustomerId), DateTime.Parse(ProcessDate));

                _doc.NewPage();

                //para = new Paragraph(CustomerName);
                //Chapter chap = new Chapter(para, i);
                //Section section1 = chap.AddSection(20f, "Section 1.1", 1);
                //_doc.Add(chap);

                foreach (DataRow vRow in dtVin.Rows)
                {

                    j++;
                    Vin = string.Empty;

                    Vin = vRow["Vin"].ToString();
                    Bus = vRow["Bus"].ToString();
                    VinId = int.Parse(vRow["VinID"].ToString());

                    if (j > 1)
                    {
                        _doc.NewPage();
                    }
                    //Dashboard//
                    //  sec = chap.AddSection(20f, Vin, j);
                    //PdfPTable tableHeader = GenerateBatteryAllCustHeader(ProcessDate, CustomerName, Vin, Bus);
                    //_doc.Add(tableHeader);
                    para = new Paragraph(Bus.ToUpper());
                    Chapter chap = new Chapter(para, j);
                    _doc.Add(chap);
                    string imageURL_VinDash = Path.Combine(TempFolderPath, string.Format("VinDashboard_{0}.png", vRow["VinID"].ToString()));

                    //iTextSharp.text.Image jpg_VinDash = iTextSharp.text.Image.GetInstance(imageURL_VinDash);
                    ////Resize image depend upon your need
                    ////jpg.ScaleToFit(chartWidth, chartHeight);
                    //// jpg_VinHist.ScaleToFit(600f, 250f);
                    //jpg_VinDash.ScalePercent(75f);

                    ////Give space before image
                    //jpg_VinDash.SpacingBefore = 10f;
                    ////Give some space after the image
                    //jpg_VinDash.SpacingAfter = 1f;
                    //jpg_VinDash.Alignment = Element.ALIGN_CENTER;
                    //_doc.Add(jpg_VinDash);

                    PdfPTable tablebat = GenerateBatteryVinDashboard(ProcessDate, VinId);
                    _doc.Add(tablebat);

                    //TMaxByPacks//
                    string imageURL_TMaxByPacks = Path.Combine(TempFolderPath, string.Format("TMaxByPacks_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_TMaxByPacks = iTextSharp.text.Image.GetInstance(imageURL_TMaxByPacks);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_TMaxByPacks.ScalePercent(60f);

                    //Give space before image
                    jpg_TMaxByPacks.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_TMaxByPacks.SpacingAfter = 1f;
                    jpg_TMaxByPacks.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_TMaxByPacks);

                    //CurrentByPacks//
                    string imageURL_CurrentByPacks = Path.Combine(TempFolderPath, string.Format("CurrentByPacks_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_CurrentByPacks = iTextSharp.text.Image.GetInstance(imageURL_CurrentByPacks);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_CurrentByPacks.ScalePercent(60f);

                    //Give space before image
                    jpg_CurrentByPacks.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_CurrentByPacks.SpacingAfter = 1f;
                    jpg_CurrentByPacks.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_CurrentByPacks);

                    //SoCByPacks_Min//
                    string imageURL_SoCByPacks_Min = Path.Combine(TempFolderPath, string.Format("SoCByPacks_Min_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_SoCByPacks_Min = iTextSharp.text.Image.GetInstance(imageURL_SoCByPacks_Min);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_SoCByPacks_Min.ScalePercent(60f);

                    //Give space before image
                    jpg_SoCByPacks_Min.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_SoCByPacks_Min.SpacingAfter = 1f;
                    jpg_SoCByPacks_Min.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_SoCByPacks_Min);

                    //SoCByPacks_Max//
                    string imageURL_SoCByPacks_Max = Path.Combine(TempFolderPath, string.Format("SoCByPacks_Max_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_SoCByPacks_Max = iTextSharp.text.Image.GetInstance(imageURL_SoCByPacks_Max);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_SoCByPacks_Max.ScalePercent(60f);

                    //Give space before image
                    jpg_SoCByPacks_Max.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_SoCByPacks_Max.SpacingAfter = 1f;
                    jpg_SoCByPacks_Max.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_SoCByPacks_Max);

                    //CurrentByPacks

                }

            }
        }
Beispiel #16
0
 /**
 * Constructs a RtfSection for a given Section. If the autogenerateTOCEntries
 * property of the RtfDocument is set and the title is not empty then a TOC entry
 * is generated for the title.
 *
 * @param doc The RtfDocument this RtfSection belongs to
 * @param section The Section this RtfSection is based on
 */
 public RtfSection(RtfDocument doc, Section section)
     : base(doc)
 {
     items = new ArrayList();
     try {
         if (section.Title != null) {
             this.title = (RtfParagraph) doc.GetMapper().MapElement(section.Title);
         }
         if (document.GetAutogenerateTOCEntries()) {
             StringBuilder titleText = new StringBuilder();
             foreach (IElement element in section.Title) {
                 if (element.Type == Element.CHUNK) {
                     titleText.Append(((Chunk) element).Content);
                 }
             }
             if (titleText.ToString().Trim().Length > 0) {
                 FD.RtfTOCEntry tocEntry = new FD.RtfTOCEntry(titleText.ToString());
                 tocEntry.SetRtfDocument(this.document);
                 this.items.Add(tocEntry);
             }
         }
         foreach (IElement element in section) {
             IRtfBasicElement rtfElement = doc.GetMapper().MapElement(element);
             if (rtfElement != null) {
                 items.Add(rtfElement);
             }
         }
         UpdateIndentation(section.IndentationLeft, section.IndentationRight, section.Indentation);
     } catch (DocumentException) {
     }
 }
Beispiel #17
0
 /// <summary>
 /// Adds a Section to this Section and returns it.
 /// </summary>
 /// <param name="title">the title of the new section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(string title)
 {
     Section section = new Section(new Paragraph(title), numberDepth + 1);
     Add(section);
     return section;
 }
Beispiel #18
0
 /// <summary>
 /// Creates a given Section following a set of attributes and adds it to this one.
 /// </summary>
 /// <param name="attributes">the attributes</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(Properties attributes)
 {
     Section section = new Section(new Paragraph(""), 1);
     string value;
     if ((value = attributes.Remove(ElementTags.NUMBER)) != null) {
         subsections = int.Parse(value) - 1;
     }
     if ((value = attributes.Remove(ElementTags.BOOKMARKOPEN)) != null) {
         this.BookmarkOpen = bool.Parse(value);
     }
     section.Set(attributes);
     Add(section);
     return section;
 }
Beispiel #19
0
 public static Section GetSection(Section parent, Properties attributes)
 {
     Section section = parent.AddSection("");
     SetSectionParameters(section, attributes);
     return section;
 }
Beispiel #20
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);
        }
Beispiel #21
0
 // methods that return a Section
 /// <summary>
 /// Creates a Section, adds it to this Section and returns it.
 /// </summary>
 /// <param name="indentation">the indentation of the new section</param>
 /// <param name="title">the title of the new section</param>
 /// <param name="numberDepth">the numberDepth of the section</param>
 /// <returns>the newly added Section</returns>
 public virtual Section AddSection(float indentation, Paragraph title, int numberDepth)
 {
     if (AddedCompletely) {
         throw new InvalidOperationException("This LargeElement has already been added to the Document.");
     }
     Section section = new Section(title, numberDepth);
     section.Indentation = indentation;
     Add(section);
     return section;
 }
Beispiel #22
0
 private static void SetSectionParameters(Section section, Properties attributes)
 {
     String value;
     value = attributes[ElementTags.NUMBERDEPTH];
     if (value != null) {
         section.NumberDepth = int.Parse(value);
     }
     value = attributes[ElementTags.INDENT];
     if (value != null) {
         section.Indentation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
     }
     value = attributes[ElementTags.INDENTATIONLEFT];
     if (value != null) {
         section.IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
     }
     value = attributes[ElementTags.INDENTATIONRIGHT];
     if (value != null) {
         section.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
     }
 }
Beispiel #23
0
 /**
 * Write the beginning of a new <code>Section</code>
 *
 * @param sectionElement The <code>Section</code> be written
 * @param outp The <code>MemoryStream</code> to write to
 *
 * @throws IOException
 * @throws DocumentException
 */
 private void WriteSection(Section sectionElement, MemoryStream outp)
 {
     if (sectionElement.Type == Element.CHAPTER) {
         outp.WriteByte(escape);
         outp.Write(sectionDefaults, 0, sectionDefaults.Length);
         WriteSectionDefaults(outp);
     }
     if (sectionElement.Title != null) {
         if (writeTOC) {
             StringBuilder title = new StringBuilder();
             foreach (Chunk ck in sectionElement.Title.Chunks) {
                 title.Append(ck.Content);
             }
             Add(new RtfTOCEntry(title.ToString(), sectionElement.Title.Font));
         } else {
             Add(sectionElement.Title);
         }
         outp.WriteByte(escape);
         outp.Write(paragraph, 0, paragraph.Length);
     }
     sectionElement.Process(this);
     if (sectionElement.Type == Element.CHAPTER) {
         outp.WriteByte(escape);
         outp.Write(section, 0, section.Length);
     }
     if (sectionElement.Type == Element.SECTION) {
         outp.WriteByte(escape);
         outp.Write(paragraph, 0, paragraph.Length);
     }
 }