public static void TestPdfRepositoryV1() { GetXmlDataFromDatatBase(); //Sample XML //var xml = CreateXml(); #region -- ******************************* -- // https://ehikioya.com/get-xml-document-nodes-recursively/ XmlReader xmlFile; xmlFile = XmlReader.Create("..\\..\\Employees.xml", new XmlReaderSettings()); DataSet ds = new DataSet(); ds.ReadXml(xmlFile); int i = 0; for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { Console.WriteLine(" ===> " + ds.Tables[0].Rows[i].ItemArray[2].ToString()); } // - Search in XML -- DataView dv; dv = new DataView(ds.Tables[0]); //dv.Sort = "Product_Name"; //int index = dv.Find("Product2"); #endregion XElement xelement = XElement.Load("..\\..\\Employees.xml"); var employees = (from nm in xelement.Elements("Employee") select nm).ToList(); XDocument xml = XDocument.Load("..\\..\\Employees.xml"); foreach (XElement element in xml.Descendants()) { Console.WriteLine(element.Name); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load("..\\..\\Employees.xml"); XmlNodeList xnList = xmlDocument.SelectNodes("/Employees/Employee"); foreach (XmlNode xn in xnList) { string id = xn["EmpId"].InnerText; string lastName = xn["Name"].InnerText; string sex = xn["EmpId"].InnerText; string phone = xn["Phone"].InnerText; Console.WriteLine("Employee : {0} {1} {2} {3}", id, lastName, sex, phone); } //File to write to var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.pdf"); //Standard PDF creation, nothing special here using (var fs = new FileStream(testFile, FileMode.Create, FileAccess.Write, FileShare.None)) { using (var doc = new Document()) { using (var writer = PdfWriter.GetInstance(doc, fs)) { doc.Open(); //Count the columns var columnCount = xml.Root.Elements("Employee").First().Nodes().Count(); //Create a table with one column for every child node of <cd> var t = new PdfPTable(columnCount); //Flag that the first row should be repeated on each page break t.HeaderRows = 1; //Loop through the first item to output column headers foreach (var N in xml.Root.Elements("Employee").First().Elements()) { t.AddCell(N.Name.ToString()); } //Loop through each CD row (this is so we can call complete later on) foreach (var CD in xml.Root.Elements()) { //Loop through each child of the current CD. Limit the number of children to our initial count just in case there are extra nodes. foreach (var N in CD.Elements().Take(columnCount)) { t.AddCell(N.Value); } //Just in case any rows have too few cells fill in any blanks t.CompleteRow(); } //Add the table to the document doc.Add(t); doc.Close(); Process.Start(testFile); } } } }
public ActionResult ExportPDF(DateTime start, DateTime end) { List <Report> list = ReportList(start, end).ToList(); #region declaration int maxColumn = 6; PdfPTable pdf = new PdfPTable(maxColumn); MemoryStream memory = new MemoryStream(); #endregion #region Document document = new Document(); document.SetPageSize(PageSize.A4); document.SetMargins(30f, 30f, 30f, 30f); pdf.WidthPercentage = 100; pdf.HorizontalAlignment = Element.ALIGN_LEFT; Font font = FontFactory.GetFont("Arial", 8f, 1); PdfWriter.GetInstance(document, memory); document.Open(); pdf.SetWidths(new float[] { 10f, 80f, 40f, 40f, 40f, 40f }); #endregion #region Header font = FontFactory.GetFont("Tahoma", 11f, 1); PdfPCell cell = new PdfPCell(new Phrase("Report List", font)); cell.Colspan = maxColumn; cell.Border = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = BaseColor.WHITE; cell.ExtraParagraphSpace = 0; pdf.AddCell(cell); pdf.CompleteRow(); font = FontFactory.GetFont("Tahoma", 9f, 1); cell = new PdfPCell(new Phrase("", font)); cell.Colspan = maxColumn; cell.Border = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = BaseColor.WHITE; cell.ExtraParagraphSpace = 2; pdf.AddCell(cell); pdf.CompleteRow(); #endregion #region Body #region Table Header font = FontFactory.GetFont("Tahoma", 8f, 1); cell = new PdfPCell(new Phrase("No", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); cell = new PdfPCell(new Phrase("Product Name", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); cell = new PdfPCell(new Phrase("Qty In", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); cell = new PdfPCell(new Phrase("Purchase", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); cell = new PdfPCell(new Phrase("Qty Out", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); cell = new PdfPCell(new Phrase("Sale", font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.LIGHT_GRAY; pdf.AddCell(cell); pdf.CompleteRow(); #endregion #region Table Body font = FontFactory.GetFont("Tahoma", 8f, 0); int number = 1; foreach (var report in list) { cell = new PdfPCell(new Phrase(number++.ToString(), font)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); cell = new PdfPCell(new Phrase(report.Product, font)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); cell = new PdfPCell(new Phrase(report.QtyIn.ToString(), font)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); cell = new PdfPCell(new Phrase(report.Purchase.ToString(), font)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); cell = new PdfPCell(new Phrase(report.QtyOut.ToString(), font)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); cell = new PdfPCell(new Phrase(report.Sale.ToString(), font)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.BackgroundColor = BaseColor.WHITE; pdf.AddCell(cell); pdf.CompleteRow(); } #endregion #endregion pdf.HeaderRows = 2; document.Add(pdf); document.Close(); byte[] file = memory.ToArray(); //return File(file, "application/pdf"); return(File( fileContents: file, contentType: "application/pdf", fileDownloadName: "ReportList.pdf")); }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); dt = Util.Now; doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); var roles = DbUtil.Db.CurrentRoles(); var i = (from o in DbUtil.Db.Organizations where o.LimitToRole == null || roles.Contains(o.LimitToRole) where o.OrganizationId == orgid select new { o.OrganizationName, o.LeaderName, o.FirstMeetingDate }).SingleOrDefault(); w.PageEvent = new HeadFoot { HeaderText = "Recent Attendee Report: {0} - {1} ({2})".Fmt( i.OrganizationName, i.LeaderName, i.FirstMeetingDate.HasValue ? "since " + i.FirstMeetingDate.FormatDate() : "no First Meeting Date set"), FooterText = "Recent Attendee Report" }; doc.Open(); var q = Attendees(orgid.Value); if (!orgid.HasValue || i == null || q.Count() == 0) { doc.Add(new Phrase("no data")); } else { var mt = new PdfPTable(1); mt.SetNoPadding(); mt.HeaderRows = 1; float[] widths = new float[] { 4f, 6f, 7f, 2.6f, 2f, 3f }; var t = new PdfPTable(widths); t.DefaultCell.Border = PdfPCell.NO_BORDER; t.DefaultCell.VerticalAlignment = PdfPCell.ALIGN_TOP; t.DefaultCell.SetLeading(2.0f, 1f); t.WidthPercentage = 100; t.AddHeader("Name", boldfont); t.AddHeader("Address", boldfont); t.AddHeader("Phone/Email", boldfont); t.AddHeader("Last Att.", boldfont); t.AddHeader("Birthday", boldfont); t.AddHeader("Status", boldfont); mt.AddCell(t); var color = BaseColor.BLACK; bool?v = null; foreach (var p in q) { if (color == BaseColor.WHITE) { color = new GrayColor(240); } else { color = BaseColor.WHITE; } t = new PdfPTable(widths); t.SetNoBorder(); t.DefaultCell.VerticalAlignment = Element.ALIGN_TOP; t.DefaultCell.BackgroundColor = color; if (v != p.visitor) { t.Add(" ------ {0} ------".Fmt(p.visitor == true ? "Guests and Previous Members" : "Members"), 6, bigboldfont); } v = p.visitor; t.Add(p.Name, font); var ph = new Paragraph(); ph.AddLine(p.Address, font); ph.AddLine(p.Address2, font); ph.AddLine(p.CSZ, font); t.AddCell(ph); ph = new Paragraph(); ph.AddLine(p.HomePhone.FmtFone("H"), font); ph.AddLine(p.CellPhone.FmtFone("C"), font); ph.AddLine(p.Email, font); t.AddCell(ph); t.Add(p.LastAttend.FormatDate(), font); t.Add(p.Birthday, font); t.Add(p.AttendType, font); t.CompleteRow(); t.Add("", font); t.Add(p.AttendStr, 4, monofont); t.AddRight("{0:n1}{1}".Fmt(p.AttendPct, p.AttendPct.HasValue ? "%" : ""), font); mt.AddCell(t); } doc.Add(mt); } doc.Close(); }
private void ReportBody() { #region Table Header _fontstyle = FontFactory.GetFont("Tahoma", 9f, 1); _pdfPCell = new PdfPCell(new Phrase("No.", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase("User Id", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase("Name", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase("Date", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase("Check In", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase("Check Out", _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.LightGray; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); #endregion #region Table Body _fontstyle = FontFactory.GetFont("Tahoma", 8f, 0); int serialNumber = 1; foreach (Absence absence in _absences) { _pdfPCell = new PdfPCell(new Phrase(serialNumber++.ToString(), _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase(absence.User.UserName, _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase(absence.User.Employee.Name, _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase(absence.TimeIn.ToString("yyyy-MMM-dd"), _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); _pdfPCell = new PdfPCell(new Phrase(absence.TimeIn.ToString("HH:mm"), _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); var updatedAt = absence.TimeOut.Year < 2000 ? "Not checked out" : absence.TimeOut.ToString("HH:mm"); _pdfPCell = new PdfPCell(new Phrase(updatedAt, _fontstyle)); _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfPCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); } #endregion }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); dt = Util.Now; doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); var i = (from m in DbUtil.Db.Meetings where m.MeetingId == mtgid select new { m.Organization.OrganizationName, m.Organization.LeaderName, m.MeetingDate }).SingleOrDefault(); w.PageEvent = new HeadFoot { HeaderText = $"Guests/Absents Report: {i.OrganizationName} - {i.LeaderName} {i.MeetingDate:g}", FooterText = "Guests/Absents Report" }; doc.Open(); var q = VisitsAbsents(mtgid.Value); if (!mtgid.HasValue || i == null || !q.Any()) { doc.Add(new Paragraph("no data")); } else { var mt = new PdfPTable(1); mt.SetNoPadding(); mt.HeaderRows = 1; float[] widths = { 4f, 6f, 7f, 2.6f, 2f, 3f }; var t = new PdfPTable(widths); t.DefaultCell.Border = Rectangle.NO_BORDER; t.DefaultCell.VerticalAlignment = Element.ALIGN_TOP; t.DefaultCell.SetLeading(2.0f, 1f); t.WidthPercentage = 100; t.AddHeader("Name", boldfont); t.AddHeader("Address", boldfont); t.AddHeader("Phone/Email", boldfont); t.AddHeader("Last Att.", boldfont); t.AddHeader("Birthday", boldfont); t.AddHeader("Guest/Member", boldfont); mt.AddCell(t); var color = BaseColor.BLACK; bool?v = null; foreach (var p in q) { if (color == BaseColor.WHITE) { color = new GrayColor(240); } else { color = BaseColor.WHITE; } t = new PdfPTable(widths); t.SetNoBorder(); t.DefaultCell.VerticalAlignment = Element.ALIGN_TOP; t.DefaultCell.BackgroundColor = color; if (v != p.visitor) { t.Add($" ------ {(p.visitor ? "Guests" : "Absentees")} ------", 6, bigboldfont); } v = p.visitor; t.Add(p.Name, font); var ph = new Paragraph(); ph.AddLine(p.Address, font); ph.AddLine(p.Address2, font); ph.AddLine(p.CSZ, font); t.AddCell(ph); ph = new Paragraph(); ph.AddLine(p.HomePhone.FmtFone("H"), font); ph.AddLine(p.CellPhone.FmtFone("C"), font); ph.AddLine(p.Email, font); t.AddCell(ph); t.Add(p.LastAttend.FormatDate(), font); t.Add(p.Birthday, font); t.Add(p.Status, font); t.CompleteRow(); if (p.Status == null || !p.Status.StartsWith("Visit")) { t.Add("", font); t.Add($"{p.AttendStr} {p.AttendPct:n1}{(p.AttendPct.HasValue ? "%" : "")}", 5, monofont); } mt.AddCell(t); } doc.Add(mt); } doc.Close(); }
private void ReportHeader() { //Image slika = Image.GetInstance("https://image.ibb.co/n6Afax/rsz_sevdahlogo_color_v1.png"); //_document.Add(slika); Image slika = Image.GetInstance("wwwroot/images/SevdahLogo_Color_v1.png"); slika.ScaleAbsoluteHeight(70); slika.ScaleAbsoluteWidth(51); _document.Add(slika); _fontStyle = FontFactory.GetFont("Tahoma", 13f, 1); _pdfPCell = new PdfPCell(new Phrase("Pržionica kafe", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 13f, 1); _pdfPCell = new PdfPCell(new Phrase("O.R \"Sevdah\"", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("BISCE POLJE b.b", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("Mostar", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("Tel: 061-164-879", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("Email: [email protected]", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("ŽIRO-RACUN br. 194-105-11436011-88", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("Pro Credit Bank", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("ID: 4327537010006", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("PDV: 327537010006", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); // PODACI O KUPCU _fontStyle = FontFactory.GetFont("Tahoma", 14f, 1); _pdfPCell = new PdfPCell(new Phrase("KUPAC:", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 5f; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1); _pdfPCell = new PdfPCell(new Phrase(this._racunPodaci.racun.Kupac.NazivKupca, _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase(this._racunPodaci.racun.Kupac.Grad.Naziv, _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); if (_racunPodaci.racun.Kupac.NazivKupca == "---") { _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); } else { _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("ID: " + this._racunPodaci.racun.Kupac.ID_broj, _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); } if (_racunPodaci.racun.Kupac.NazivKupca == "---") { _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = Rectangle.BOTTOM_BORDER; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfPCell.PaddingBottom = 10f; _pdfTable.AddCell(_pdfPCell); } else { _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("PDV: " + this._racunPodaci.racun.Kupac.PDV_broj, _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfPCell.Border = Rectangle.BOTTOM_BORDER; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfPCell.PaddingBottom = 10f; _pdfTable.AddCell(_pdfPCell); } _fontStyle = FontFactory.GetFont("Arial", 18f, 1); _pdfPCell = new PdfPCell(new Phrase("PREDRACUN", _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.PaddingTop = 15f; _pdfPCell.PaddingBottom = 15f; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _fontStyle = FontFactory.GetFont("Tahoma", 14f, 1, BaseColor.DARK_GRAY); _pdfPCell = new PdfPCell(new Phrase("Broj predracuna: " + this._racunPodaci.racun.BrojRacuna, _fontStyle)); _pdfPCell.Colspan = _totalColumns; _pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfPCell.Border = 0; _pdfPCell.PaddingTop = 10f; _pdfPCell.PaddingBottom = 15f; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); }
private void ReportBody() { var fontStyleBold = FontFactory.GetFont("Times New Roman", 9f, 1); _fontStyle = FontFactory.GetFont("Times New Roman", 9f, 0); #region Detalhes cabeçalho da tabela principal _pdfCell = new PdfPCell(new Phrase("ID", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("NOME", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("QTD", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("VALOR", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("ATIVO", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("CATEGORIA", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); #endregion #region Detalhes corpo da tebela foreach (var oProduto in _oProdutos) { _pdfCell = new PdfPCell(new Phrase(oProduto.Id.ToString(), _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase(oProduto.Nomeprod, _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase(oProduto.Quantidade.ToString())); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase(oProduto.Valorprod.ToString("C"))); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfTable.AddCell(_pdfCell); if (oProduto.Ativo) { _pdfCell = new PdfPCell(new Phrase("Sim")); } else { _pdfCell = new PdfPCell(new Phrase("Não")); } _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase(oProduto.CategoriaId.ToString())); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); } #endregion }
private void ReportSubHeader() { var fontStyleBold = FontFactory.GetFont("Calibri", 9f, 1); _fontStyle = FontFactory.GetFont("Calibri", 9f, 0); #region Detalhes sub cabeçalho da tabela principal _pdfCell = new PdfPCell(new Phrase("TOTAL DE PRODUTOS", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTableSubHeader.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("TT PEÇAS:", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTableSubHeader.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("VALOR ESTOQUE", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTableSubHeader.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("ATUALIZADO EM", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.GRAY; _pdfTableSubHeader.AddCell(_pdfCell); _pdfTableSubHeader.CompleteRow(); _pdfCell = new PdfPCell(new Phrase(_oProdutos.Count().ToString(), _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTableSubHeader.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("15", _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTableSubHeader.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("25", _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTableSubHeader.AddCell(_pdfCell); string dataHoraLocal = DateTime.Now.Date.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); _pdfCell = new PdfPCell(new Phrase(dataHoraLocal, _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfTableSubHeader.AddCell(_pdfCell); _pdfTableSubHeader.CompleteRow(); #endregion }
public ActionResult Printaj(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Racuni r = db.RacuniDbSet.Find(id); if (r == null) { return(HttpNotFound()); } RacunPrintajVM model = db.RacuniDbSet .Where(x => x.Id == id) .Select(f => new RacunPrintajVM { Id = f.Id, Placen = f.Placen ? "DA" : "NE", DatumIzdavanja = f.DatumIzdavanja, KorisnikId = f.KorisnikId, PeriodDo = f.ObracunskiPeriodDO, PeriodOd = f.ObracunskiPeriodOD, RokPlacanja = f.RokPlacanja, Sifra = f.Sifra, Ukupno = f.UkupnoBezPDV.ToString(), PDF = (f.UkupnoSaPDV - f.UkupnoBezPDV).ToString(), UkupnoPDV = f.UkupnoSaPDV.ToString(), }).Single(); model.Korisnik = db.KorisnikDbSet.Find(model.KorisnikId); model.ListaStavki = db.RacuniStavkeDbSet.Where(g => g.RacunId == model.Id).ToList(); PdfPTable pdftabela = new PdfPTable(2); PdfPTable tabela3 = new PdfPTable(3); PdfPTable tabelaUsluge = new PdfPTable(7); PdfPTable tabelaTotal = new PdfPTable(5); PdfPCell celija; string FONT = "c:/Windows/Fonts/arial.ttf"; Font font = FontFactory.GetFont(FONT, BaseFont.IDENTITY_H, true); using (MemoryStream ms = new MemoryStream()) { Document document = new Document(); document.SetPageSize(PageSize.A4); document.SetMargins(50f, 50f, 20f, 20f); pdftabela.WidthPercentage = 100; pdftabela.HorizontalAlignment = Element.ALIGN_LEFT; tabela3.WidthPercentage = 100; tabela3.HorizontalAlignment = Element.ALIGN_LEFT; tabelaUsluge.WidthPercentage = 100; tabelaUsluge.HorizontalAlignment = Element.ALIGN_LEFT; tabelaTotal.WidthPercentage = 100; tabelaTotal.HorizontalAlignment = Element.ALIGN_LEFT; PdfWriter writer = PdfWriter.GetInstance(document, ms); document.Open(); BaseFont nf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, false); BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, false); var Sivaboja = new BaseColor(25, 25, 25); Font fontsadrzaj = new Font(nf, 11); Font font8 = new Font(nf, 8); Font font8bold = new Font(bf, 8); Font font11 = new Font(nf, 11); Font font9 = new Font(nf, 9); Font font10 = new Font(nf, 10); Font font11bold = new Font(bf, 11); Font font16Bold = new Font(bf, 16); Font font16 = new Font(nf, 16); Font font20 = new Font(nf, 18); string putanja = Server.MapPath("~/Slike/"); Image header = Image.GetInstance(putanja + "header.png"); ////////////////////////////////////////////////////////////////////////// header.ScaleToFit(PageSize.A4.Width - 90f, 80f); header.SpacingBefore = 10f; header.SpacingAfter = 10f; header.Alignment = Element.ALIGN_LEFT; document.Add(header); ////////////////////////////////////////////////////////////////////////// pdftabela.SetWidths(new float[] { 160f, 100f }); tabela3.SetWidths(new float[] { 50, 40, 50 }); tabelaUsluge.SetWidths(new float[] { 35, 35, 35, 35, 35, 35, 35 }); tabelaTotal.SetWidths(new float[] { 50, 50, 50, 50, 50 }); #region tijelo pdftabela.SpacingBefore = 50f; celija = new PdfPCell(new Phrase("RAČUN - " + model.Sifra, font20)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; pdftabela.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; pdftabela.AddCell(celija); //celija = new PdfPCell(new Phrase("Sifra " + model.Sifra, font11)); //celija.HorizontalAlignment = Element.ALIGN_RIGHT; //celija.VerticalAlignment = Element.ALIGN_MIDDLE; //celija.BackgroundColor = BaseColor.WHITE; //celija.Border = Rectangle.NO_BORDER; //pdftabela.AddCell(celija); tabela3.SpacingBefore = 50f; #endregion document.Add(pdftabela); celija = new PdfPCell(new Phrase("Klijent: ", font11bold)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 25f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Detalji o računu: ", font11bold)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.MinimumHeight = 25f; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Ime + " " + model.Korisnik.Prezime, font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Datum izdavanja: " + model.DatumIzdavanja.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.MinimumHeight = 16f; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Adresa + " ", font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Period od: " + model.PeriodOd.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Opcina.NazivOpcine, font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Period od: " + model.PeriodDo.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); document.Add(tabela3); tabelaUsluge.SpacingBefore = 50f; celija = new PdfPCell(new Phrase("USLUGA ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("NAZIV ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("DATUM OD ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("DATUM DO ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("CIJENA ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("PDV ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("UKUPNO ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); ///////////////////////////////////////////////////////////////// tabelaUsluge.CompleteRow(); ///////////////////////////////////////////////////////////////// foreach (var item in model.ListaStavki) { celija = new PdfPCell(new Phrase(item.AktivnaUsluga.Paket.Naziv, font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.AktivnaUsluga.Paket.TipUsluga.Naziv, font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.DatumPocetka.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.DatumKraja.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.IznosBezPDV.ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase((item.IznosSaPDV - item.IznosBezPDV).ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.IznosSaPDV.ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); //////////////////////////////////////////////////////////////////////// tabelaUsluge.CompleteRow(); /////////////////////////////////////////////////////////////////////////// } tabelaUsluge.CompleteRow(); document.Add(tabelaUsluge); //////////////////////////////////////////////////////////////////////// tabelaTotal.SpacingBefore = 100f; celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("Ukupno bez PDV", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("PDV 17%", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("Ukupno sa PDV", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); tabelaTotal.CompleteRow(); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.Ukupno.ToString(), font16)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.PDF, font16)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.UkupnoPDV, font16Bold)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); tabelaTotal.CompleteRow(); document.Add(tabelaTotal); document.Close(); byte[] bytes = ms.ToArray(); ms.Close(); return(File(bytes, "application/pdf")); } }
public MemoryStream GeneratePdfTemplate(RO_GarmentViewModel viewModel) { //set pdf stream MemoryStream stream = new MemoryStream(); Document document = new Document(PageSize.A4, 10, 10, 10, 10); PdfWriter writer = PdfWriter.GetInstance(document, stream); writer.CloseStream = false; document.Open(); PdfContentByte cb = writer.DirectContent; //set content configuration BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); BaseFont bf_bold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7); Font bold_font_8 = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font font_9 = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9); DateTime now = DateTime.Now; float margin = 10; float printedOnHeight = 10; float startY = 840 - margin; #region Header cb.BeginText(); cb.SetFontAndSize(bf, 10); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "PT. EFRATA RETAILINDO", 10, 820, 0); cb.SetFontAndSize(bf_bold, 12); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "RO PENJUALAN UMUM", 10, 805, 0); cb.EndText(); #endregion #region Top PdfPTable table_top = new PdfPTable(9); float[] top_widths = new float[] { 1f, 0.1f, 2f, 1f, 0.1f, 2f, 1f, 0.1f, 2f }; table_top.TotalWidth = 500f; table_top.SetWidths(top_widths); PdfPCell cell_top = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; PdfPCell cell_colon = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE }; PdfPCell cell_top_keterangan = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2, Colspan = 7 }; cell_colon.Phrase = new Phrase(":", normal_font); cell_top.Phrase = new Phrase("NO RO", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.RO}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("SECTION", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.Section}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("DATE", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.ConfirmDate.ToString("dd MMMM yyyy")}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("LINE", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.Line.Name}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("BUYER", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.Buyer.Name}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("DELIVERY DATE", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.DeliveryDate.ToString("dd MMMM yyyy")}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("DESC", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.Description}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("QUANTITY", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.Total.ToString()}", normal_font); table_top.AddCell(cell_top); cell_top.Phrase = new Phrase("SIZE RANGE", normal_font); table_top.AddCell(cell_top); table_top.AddCell(cell_colon); cell_top.Phrase = new Phrase($"{viewModel.CostCalculationGarment.SizeRange.Name}", normal_font); table_top.AddCell(cell_top); byte[] imageByte; float imageHeight; try { imageByte = Convert.FromBase64String(Base64.GetBase64File(viewModel.CostCalculationGarment.ImageFile)); Image image = Image.GetInstance(imgb: imageByte); if (image.Width > 60) { float percentage = 0.0f; percentage = 60 / image.Width; image.ScalePercent(percentage * 100); } float imageY = 800 - image.ScaledHeight; imageHeight = image.ScaledHeight; image.SetAbsolutePosition(520, imageY); cb.AddImage(image, inlineImage: true); } catch (Exception) { imageHeight = 0; } float row1Y = 800; table_top.WriteSelectedRows(0, -1, 10, row1Y, cb); #endregion #region Table Fabric //Fabric title PdfPTable table_fabric_top = new PdfPTable(1); table_fabric_top.TotalWidth = 500f; float[] fabric_widths_top = new float[] { 5f }; table_fabric_top.SetWidths(fabric_widths_top); PdfPCell cell_top_fabric = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; cell_top_fabric.Phrase = new Phrase("FABRIC", bold_font); table_fabric_top.AddCell(cell_top_fabric); float row1Height = imageHeight > table_top.TotalHeight ? imageHeight : table_top.TotalHeight; float rowYTittleFab = row1Y - row1Height - 10; float allowedRow2Height = rowYTittleFab - printedOnHeight - margin; table_fabric_top.WriteSelectedRows(0, -1, 10, rowYTittleFab, cb); //Main fabric table PdfPTable table_fabric = new PdfPTable(5); table_fabric.TotalWidth = 500f; float[] fabric_widths = new float[] { 5f, 5f, 5f, 5f, 5f }; table_fabric.SetWidths(fabric_widths); PdfPCell cell_fabric_center = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_fabric_left = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; float rowYFab = rowYTittleFab - table_fabric_top.TotalHeight - 5; float allowedRow2HeightFab = rowYFab - printedOnHeight - margin; cell_fabric_center.Phrase = new Phrase("FABRIC", bold_font); table_fabric.AddCell(cell_fabric_center); cell_fabric_center.Phrase = new Phrase("NAME", bold_font); table_fabric.AddCell(cell_fabric_center); cell_fabric_center.Phrase = new Phrase("DESCRIPTION", bold_font); table_fabric.AddCell(cell_fabric_center); cell_fabric_center.Phrase = new Phrase("QUANTITY", bold_font); table_fabric.AddCell(cell_fabric_center); cell_fabric_center.Phrase = new Phrase("REMARK", bold_font); table_fabric.AddCell(cell_fabric_center); foreach (var materialModel in viewModel.CostCalculationGarment.CostCalculationGarment_Materials) { if (materialModel.Category.Name == "FAB") { cell_fabric_left.Phrase = new Phrase(materialModel.Category.SubCategory != null ? materialModel.Category.SubCategory : "", normal_font); table_fabric.AddCell(cell_fabric_left); cell_fabric_left.Phrase = new Phrase(materialModel.Material.Name != null ? materialModel.Material.Name : "", normal_font); table_fabric.AddCell(cell_fabric_left); cell_fabric_left.Phrase = new Phrase(materialModel.Description != null ? materialModel.Description : "", normal_font); table_fabric.AddCell(cell_fabric_left); cell_fabric_left.Phrase = new Phrase(materialModel.Quantity.ToString() != null ? String.Format("{0} " + materialModel.UOMQuantity.Name, materialModel.Quantity.ToString()) : "0", normal_font); table_fabric.AddCell(cell_fabric_left); cell_fabric_left.Phrase = new Phrase(materialModel.Information != null ? materialModel.Information : "", normal_font); table_fabric.AddCell(cell_fabric_left); } } table_fabric.WriteSelectedRows(0, -1, 10, rowYFab, cb); #endregion #region Table Accessories //Accessories Title PdfPTable table_acc_top = new PdfPTable(1); table_acc_top.TotalWidth = 500f; float[] acc_width_top = new float[] { 5f }; table_acc_top.SetWidths(acc_width_top); PdfPCell cell_top_acc = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; cell_top_acc.Phrase = new Phrase("ACCESSORIES", bold_font); table_acc_top.AddCell(cell_top_acc); float rowYTittleAcc = rowYFab - table_fabric.TotalHeight - 10; float allowedRow2HeightTopAcc = rowYTittleFab - printedOnHeight - margin; table_acc_top.WriteSelectedRows(0, -1, 10, rowYTittleAcc, cb); //Main Accessories Table PdfPTable table_accessories = new PdfPTable(5); table_accessories.TotalWidth = 500f; float[] accessories_widths = new float[] { 5f, 5f, 5f, 5f, 5f }; table_accessories.SetWidths(accessories_widths); PdfPCell cell_acc_center = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_acc_left = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; float rowYAcc = rowYTittleAcc - table_fabric_top.TotalHeight - 5; float allowedRow2HeightAcc = rowYAcc - printedOnHeight - margin; cell_acc_center.Phrase = new Phrase("ACCESSORIES", bold_font); table_accessories.AddCell(cell_acc_center); cell_acc_center.Phrase = new Phrase("NAME", bold_font); table_accessories.AddCell(cell_acc_center); cell_acc_center.Phrase = new Phrase("DESCRIPTION", bold_font); table_accessories.AddCell(cell_acc_center); cell_acc_center.Phrase = new Phrase("QUANTITY", bold_font); table_accessories.AddCell(cell_acc_center); cell_acc_center.Phrase = new Phrase("REMARK", bold_font); table_accessories.AddCell(cell_acc_center); foreach (var materialModel in viewModel.CostCalculationGarment.CostCalculationGarment_Materials) { if (materialModel.Category.Name == "ACC") { cell_acc_left.Phrase = new Phrase(materialModel.Category.SubCategory != null ? materialModel.Category.SubCategory : "", normal_font); table_accessories.AddCell(cell_acc_left); cell_acc_left.Phrase = new Phrase(materialModel.Material.Name != null ? materialModel.Material.Name : "", normal_font); table_accessories.AddCell(cell_acc_left); cell_acc_left.Phrase = new Phrase(materialModel.Description != null ? materialModel.Description : "", normal_font); table_accessories.AddCell(cell_acc_left); cell_acc_left.Phrase = new Phrase(materialModel.Quantity != null ? String.Format("{0} " + materialModel.UOMQuantity.Name, materialModel.Quantity.ToString()) : "0", normal_font); table_accessories.AddCell(cell_acc_left); cell_acc_left.Phrase = new Phrase(materialModel.Information != null ? materialModel.Information : "", normal_font); table_accessories.AddCell(cell_acc_left); } } table_accessories.WriteSelectedRows(0, -1, 10, rowYAcc, cb); #endregion #region Table Ongkos //Ongkos Title PdfPTable table_ong_top = new PdfPTable(1); table_ong_top.TotalWidth = 500f; float[] ong_width_top = new float[] { 5f }; table_ong_top.SetWidths(ong_width_top); PdfPCell cell_top_ong = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; cell_top_ong.Phrase = new Phrase("ONGKOS", bold_font); table_ong_top.AddCell(cell_top_ong); float rowYTittleOng = rowYAcc - table_accessories.TotalHeight - 10; float allowedRow2HeightTopOng = rowYTittleOng - printedOnHeight - margin; //Main Table Ongkos PdfPTable table_budget = new PdfPTable(5); table_budget.TotalWidth = 500f; float[] budget_widths = new float[] { 5f, 5f, 5f, 5f, 5f }; table_budget.SetWidths(budget_widths); var ongIndex = 0; PdfPCell cell_budget_center = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_budget_left = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; float rowYBudget = rowYTittleOng - table_ong_top.TotalHeight - 5; float allowedRow2HeightBudget = rowYBudget - printedOnHeight - margin; cell_budget_center.Phrase = new Phrase("ONGKOS", bold_font); table_budget.AddCell(cell_budget_center); cell_budget_center.Phrase = new Phrase("NAME", bold_font); table_budget.AddCell(cell_budget_center); cell_budget_center.Phrase = new Phrase("DESCRIPTION", bold_font); table_budget.AddCell(cell_budget_center); cell_budget_center.Phrase = new Phrase("QUANTITY", bold_font); table_budget.AddCell(cell_budget_center); cell_budget_center.Phrase = new Phrase("REMARK", bold_font); table_budget.AddCell(cell_budget_center); foreach (var materialModel in viewModel.CostCalculationGarment.CostCalculationGarment_Materials) { if (materialModel.Category.Name == "ONG") { cell_budget_left.Phrase = new Phrase(materialModel.Category.SubCategory != null ? materialModel.Category.SubCategory : "", normal_font); table_budget.AddCell(cell_budget_left); cell_budget_left.Phrase = new Phrase(materialModel.Material.Name != null ? materialModel.Material.Name : "", normal_font); table_budget.AddCell(cell_budget_left); cell_budget_left.Phrase = new Phrase(materialModel.Description != null ? materialModel.Description : "", normal_font); table_budget.AddCell(cell_budget_left); cell_budget_left.Phrase = new Phrase(materialModel.Quantity != null ? String.Format("{0} " + materialModel.UOMQuantity.Name, materialModel.Quantity.ToString()) : "0", normal_font); table_budget.AddCell(cell_budget_left); cell_budget_left.Phrase = new Phrase(materialModel.Information != null ? materialModel.Information : "", normal_font); table_budget.AddCell(cell_budget_left); ongIndex++; } } if (ongIndex != 0) { table_budget.WriteSelectedRows(0, -1, 10, rowYBudget, cb); table_ong_top.WriteSelectedRows(0, -1, 10, rowYTittleOng, cb); } #endregion #region Table Size Breakdown //Title PdfPTable table_breakdown_top = new PdfPTable(1); table_breakdown_top.TotalWidth = 570f; float[] breakdown_width_top = new float[] { 5f }; table_breakdown_top.SetWidths(breakdown_width_top); PdfPCell cell_top_breakdown = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; cell_top_breakdown.Phrase = new Phrase("SIZE BREAKDOWN", bold_font); table_breakdown_top.AddCell(cell_top_breakdown); float rowYTittleBreakDown = rowYBudget - table_budget.TotalHeight - 10; float allowedRow2HeightBreakdown = rowYTittleBreakDown - printedOnHeight - margin; table_breakdown_top.WriteSelectedRows(0, -1, 10, rowYTittleBreakDown, cb); //Main Table Size Breakdown PdfPTable table_breakDown = new PdfPTable(2); table_breakDown.TotalWidth = 570f; float[] breakDown_widths = new float[] { 5f, 10f }; table_breakDown.SetWidths(breakDown_widths); PdfPCell cell_breakDown_center = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_breakDown_left = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_breakDown_total = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_breakDown_total_2 = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; float rowYbreakDown = rowYTittleBreakDown - table_breakdown_top.TotalHeight - 5; float allowedRow2HeightBreakDown = rowYbreakDown - printedOnHeight - margin; var remainingRowToHeightBrekdown = rowYbreakDown - 5 - printedOnHeight - margin; cell_breakDown_center.Phrase = new Phrase("WARNA", bold_font); table_breakDown.AddCell(cell_breakDown_center); cell_breakDown_center.Phrase = new Phrase("SIZE RANGE", bold_font); table_breakDown.AddCell(cell_breakDown_center); foreach (var productRetail in viewModel.RO_Garment_SizeBreakdowns) { if (productRetail.Total != 0) { cell_breakDown_left.Phrase = new Phrase(productRetail.Color.name != null ? productRetail.Color.name : "", normal_font); table_breakDown.AddCell(cell_breakDown_left); PdfPTable table_breakDown_child = new PdfPTable(3); table_breakDown_child.TotalWidth = 300f; float[] breakDown_child_widths = new float[] { 5f, 5f, 5f }; table_breakDown_child.SetWidths(breakDown_child_widths); PdfPCell cell_breakDown_child_center = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; PdfPCell cell_breakDown_child_left = new PdfPCell() { Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2 }; cell_breakDown_child_center.Phrase = new Phrase("KETERANGAN", bold_font); table_breakDown_child.AddCell(cell_breakDown_child_center); cell_breakDown_child_center.Phrase = new Phrase("SIZE", bold_font); table_breakDown_child.AddCell(cell_breakDown_child_center); cell_breakDown_child_center.Phrase = new Phrase("QUANTITY", bold_font); table_breakDown_child.AddCell(cell_breakDown_child_center); foreach (var size in productRetail.RO_Garment_SizeBreakdown_Details) { cell_breakDown_child_left.Phrase = new Phrase(size.Information != null ? size.Information : "", normal_font); table_breakDown_child.AddCell(cell_breakDown_child_left); cell_breakDown_child_left.Phrase = new Phrase(size.Size.Name != null ? size.Size.Name : "", normal_font); table_breakDown_child.AddCell(cell_breakDown_child_left); cell_breakDown_child_left.Phrase = new Phrase(size.Quantity.ToString() != null ? size.Quantity.ToString() : "0", normal_font); table_breakDown_child.AddCell(cell_breakDown_child_left); } cell_breakDown_child_left.Phrase = new Phrase(" ", bold_font); table_breakDown_child.AddCell(cell_breakDown_child_left); cell_breakDown_child_left.Phrase = new Phrase("TOTAL", bold_font); table_breakDown_child.AddCell(cell_breakDown_child_left); cell_breakDown_child_left.Phrase = new Phrase(productRetail.Total.ToString() != null ? productRetail.Total.ToString() : "0", normal_font); table_breakDown_child.AddCell(cell_breakDown_child_left); table_breakDown_child.WriteSelectedRows(0, -1, 10, 0, cb); table_breakDown.AddCell(table_breakDown_child); } var tableBreakdownCurrentHeight = table_breakDown.TotalHeight; if (tableBreakdownCurrentHeight / remainingRowToHeightBrekdown > 1) { if (tableBreakdownCurrentHeight / allowedRow2HeightBreakDown > 1) { PdfPRow headerRow = table_breakDown.GetRow(0); PdfPRow lastRow = table_breakDown.GetRow(table_breakDown.Rows.Count - 1); table_breakDown.DeleteLastRow(); table_breakDown.WriteSelectedRows(0, -1, 10, rowYbreakDown, cb); table_breakDown.DeleteBodyRows(); this.DrawPrintedOn(now, bf, cb); document.NewPage(); table_breakDown.Rows.Add(headerRow); table_breakDown.Rows.Add(lastRow); table_breakDown.CalculateHeights(); rowYbreakDown = startY; remainingRowToHeightBrekdown = rowYbreakDown - 5 - printedOnHeight - margin; allowedRow2HeightBreakDown = remainingRowToHeightBrekdown - printedOnHeight - margin; } } } cell_breakDown_total_2.Phrase = new Phrase("TOTAL", bold_font); table_breakDown.AddCell(cell_breakDown_total_2); cell_breakDown_total_2.Phrase = new Phrase(viewModel.Total.ToString(), bold_font); table_breakDown.AddCell(cell_breakDown_total_2); table_breakDown.WriteSelectedRows(0, -1, 10, rowYbreakDown, cb); #endregion #region Table Instruksi //Title PdfPTable table_instruction = new PdfPTable(1); float[] instruction_widths = new float[] { 5f }; table_instruction.TotalWidth = 500f; table_instruction.SetWidths(instruction_widths); PdfPCell cell_top_instruction = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2 }; PdfPCell cell_colon_instruction = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE }; PdfPCell cell_top_keterangan_instruction = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, PaddingRight = 1, PaddingBottom = 2, PaddingTop = 2, Colspan = 7 }; cell_top_instruction.Phrase = new Phrase("INSTRUCTION", normal_font); table_instruction.AddCell(cell_top_instruction); table_instruction.AddCell(cell_colon_instruction); cell_top_keterangan_instruction.Phrase = new Phrase($"{viewModel.Instruction}", normal_font); table_instruction.AddCell(cell_top_keterangan_instruction); float rowYInstruction = rowYbreakDown - table_breakDown.TotalHeight - 10; float allowedRow2HeightInstruction = rowYInstruction - printedOnHeight - margin; table_instruction.WriteSelectedRows(0, -1, 10, rowYInstruction, cb); #endregion #region RO Image var countImageRo = 0; byte[] roImage; foreach (var index in viewModel.ImagesFile) { countImageRo++; } float rowYRoImage = rowYInstruction - table_instruction.TotalHeight - 10; float imageRoHeight; if (countImageRo != 0) { PdfPTable table_ro_image = new PdfPTable(8); table_ro_image.DefaultCell.Border = Rectangle.NO_BORDER; float[] ro_widths = new float[8]; for (var i = 0; i < 8; i++) { ro_widths.SetValue(5f, i); } if (countImageRo != 0) { table_ro_image.SetWidths(ro_widths); } table_ro_image.TotalWidth = 570f; for (var i = 0; i < viewModel.ImagesFile.Count; i++) { try { roImage = Convert.FromBase64String(Base64.GetBase64File(viewModel.ImagesFile[i])); } catch (Exception) { var webClient = new WebClient(); roImage = webClient.DownloadData("https://bateeqstorage.blob.core.windows.net/other/no-image.jpg"); } Image images = Image.GetInstance(imgb: roImage); var imageName = viewModel.ImagesName[i]; if (images.Width > 60) { float percentage = 0.0f; percentage = 60 / images.Width; images.ScalePercent(percentage * 100); } PdfPCell imageCell = new PdfPCell(images); imageCell.Border = 0; imageCell.Padding = 4; PdfPCell nameCell = new PdfPCell(); nameCell.Border = 0; nameCell.Padding = 4; nameCell.Phrase = new Phrase(imageName, normal_font); PdfPTable table_ro_name = new PdfPTable(1); table_ro_name.DefaultCell.Border = Rectangle.NO_BORDER; table_ro_name.AddCell(imageCell); table_ro_name.AddCell(nameCell); table_ro_name.CompleteRow(); table_ro_image.AddCell(table_ro_name); } table_ro_image.CompleteRow(); imageRoHeight = table_ro_image.TotalHeight; table_ro_image.WriteSelectedRows(0, -1, 10, rowYRoImage, cb); } else { imageRoHeight = 0; } #endregion #region Signature PdfPTable table_signature = new PdfPTable(6); table_signature.TotalWidth = 570f; float[] signature_widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f }; table_signature.SetWidths(signature_widths); PdfPCell cell_signature = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2, }; PdfPCell cell_signature_noted = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 2, PaddingTop = 50 }; cell_signature.Phrase = new Phrase("Dibuat", normal_font); table_signature.AddCell(cell_signature); cell_signature.Phrase = new Phrase("Kasie Merchandiser", normal_font); table_signature.AddCell(cell_signature); cell_signature.Phrase = new Phrase("R & D", normal_font); table_signature.AddCell(cell_signature); cell_signature.Phrase = new Phrase("Ka Produksi", normal_font); table_signature.AddCell(cell_signature); cell_signature.Phrase = new Phrase("Mengetahui", normal_font); table_signature.AddCell(cell_signature); cell_signature.Phrase = new Phrase("Menyetujui", normal_font); table_signature.AddCell(cell_signature); cell_signature_noted.Phrase = new Phrase("( )", normal_font); table_signature.AddCell(cell_signature_noted); cell_signature_noted.Phrase = new Phrase("( )", normal_font); table_signature.AddCell(cell_signature_noted); cell_signature_noted.Phrase = new Phrase("( )", normal_font); table_signature.AddCell(cell_signature_noted); cell_signature_noted.Phrase = new Phrase("( )", normal_font); table_signature.AddCell(cell_signature_noted); cell_signature_noted.Phrase = new Phrase("(Haenis Gunarto)", normal_font); table_signature.AddCell(cell_signature_noted); cell_signature_noted.Phrase = new Phrase("(Michelle Tjokrosaputro)", normal_font); table_signature.AddCell(cell_signature_noted); float table_signatureY = rowYRoImage - imageRoHeight - 10; table_signature.WriteSelectedRows(0, -1, 10, table_signatureY, cb); #endregion this.DrawPrintedOn(now, bf, cb); document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
/* * (non-Javadoc) * * @see * com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, * java.util.List, com.itextpdf.text.Document) */ public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent) { try { bool percentage = false; String widthValue = null; tag.CSS.TryGetValue(HTML.Attribute.WIDTH, out widthValue); if (!tag.CSS.TryGetValue(HTML.Attribute.WIDTH, out widthValue) && !tag.Attributes.TryGetValue(HTML.Attribute.WIDTH, out widthValue)) { widthValue = null; } if (widthValue != null && widthValue.Trim().EndsWith("%")) { percentage = true; } int numberOfColumns = 0; List <TableRowElement> tableRows = new List <TableRowElement>(currentContent.Count); IList <IElement> invalidRowElements = new List <IElement>(1); String repeatHeader; tag.CSS.TryGetValue(CSS.Property.REPEAT_HEADER, out repeatHeader); String repeatFooter; tag.CSS.TryGetValue(CSS.Property.REPEAT_FOOTER, out repeatFooter); int headerRows = 0; int footerRows = 0; foreach (IElement e in currentContent) { int localNumCols = 0; if (e is TableRowElement) { TableRowElement tableRowElement = (TableRowElement)e; foreach (HtmlCell cell in tableRowElement.Content) { localNumCols += cell.Colspan; } if (localNumCols > numberOfColumns) { numberOfColumns = localNumCols; } tableRows.Add(tableRowElement); if (repeatHeader != null && Util.EqualsIgnoreCase(repeatHeader, "yes") && tableRowElement.RowPlace.Equals(TableRowElement.Place.HEADER)) { headerRows++; } if (repeatFooter != null && Util.EqualsIgnoreCase(repeatFooter, "yes") && tableRowElement.RowPlace.Equals(TableRowElement.Place.FOOTER)) { footerRows++; } } else { invalidRowElements.Add(e); } } if (repeatFooter == null || !Util.EqualsIgnoreCase(repeatFooter, "yes")) { InsertionSort <TableRowElement>(tableRows, delegate(TableRowElement o1, TableRowElement o2) { return(o1.RowPlace.Normal.CompareTo(o2.RowPlace.Normal)); }); } else { InsertionSort <TableRowElement>(tableRows, delegate(TableRowElement o1, TableRowElement o2) { return(o1.RowPlace.Repeated.CompareTo(o2.RowPlace.Repeated)); }); } PdfPTable table = new PdfPTable(numberOfColumns); table.HeaderRows = headerRows + footerRows; table.FooterRows = footerRows; TableStyleValues styleValues = SetStyleValues(tag); table.TableEvent = new TableBorderEvent(styleValues); SetVerticalMargin(table, tag, styleValues, ctx); WidenLastCell(tableRows, styleValues.HorBorderSpacing); float[] columnWidths = new float[numberOfColumns]; float[] widestWords = new float[numberOfColumns]; float[] fixedWidths = new float[numberOfColumns]; float[] colspanWidestWords = new float[numberOfColumns]; int[] rowspanValue = new int[numberOfColumns]; float largestColumn = 0; float largestColspanColumn = 0; int indexOfLargestColumn = -1; int indexOfLargestColspanColumn = -1; // Initial fill of the widths arrays foreach (TableRowElement row in tableRows) { int column = 0; foreach (HtmlCell cell in row.Content) { // check whether the current column should be skipped due to a // rowspan value of higher cell in this column. while (rowspanValue[column] > 1) { rowspanValue[column] = rowspanValue[column] - 1; ++column; } // sets a rowspan counter for current column (counter not // needed for last column). if (cell.Rowspan > 1 && column != numberOfColumns - 1) { rowspanValue[column] = cell.Rowspan - 1; } int colspan = cell.Colspan; if (cell.FixedWidth != 0) { float fixedWidth = cell.FixedWidth + GetCellStartWidth(cell); fixedWidth /= colspan; for (int i = 0; i < colspan; i++) { int c = column + i; if (fixedWidth > fixedWidths[c]) { fixedWidths[c] = fixedWidth; columnWidths[c] = fixedWidth; } } } if (cell.CompositeElements != null) { float[] widthValues = SetCellWidthAndWidestWord(cell); float cellWidth = widthValues[0] / colspan; float widestWordOfCell = widthValues[1] / colspan; for (int i = 0; i < colspan; i++) { int c = column + i; if (fixedWidths[c] == 0 && cellWidth > columnWidths[c]) { columnWidths[c] = cellWidth; if (colspan == 1) { if (cellWidth > largestColumn) { largestColumn = cellWidth; indexOfLargestColumn = c; } } else { if (cellWidth > largestColspanColumn) { largestColspanColumn = cellWidth; indexOfLargestColspanColumn = c; } } } if (colspan == 1) { if (widestWordOfCell > widestWords[c]) { widestWords[c] = widestWordOfCell; } } else { if (widestWordOfCell > colspanWidestWords[c]) { colspanWidestWords[c] = widestWordOfCell; } } } } if (colspan > 1) { if (LOG.IsLogging(Level.TRACE)) { LOG.Trace(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.COLSPAN), colspan)); } column += colspan - 1; } column++; } } if (indexOfLargestColumn == -1) { indexOfLargestColumn = indexOfLargestColspanColumn; if (indexOfLargestColumn == -1) { indexOfLargestColumn = 0; } for (int column = 0; column < numberOfColumns; column++) { widestWords[column] = colspanWidestWords[column]; } } float outerWidth = GetTableOuterWidth(tag, styleValues.HorBorderSpacing, ctx); float initialTotalWidth = GetTableWidth(columnWidths, 0); // float targetWidth = calculateTargetWidth(tag, columnWidths, outerWidth, ctx); float targetWidth = 0; HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx); float max = htmlPipelineContext.PageSize.Width - outerWidth; bool tableWidthFixed = false; if (tag.Attributes.ContainsKey(CSS.Property.WIDTH) || tag.CSS.ContainsKey(CSS.Property.WIDTH)) { targetWidth = new WidthCalculator().GetWidth(tag, htmlPipelineContext.GetRootTags(), htmlPipelineContext.PageSize.Width); if (targetWidth > max) { targetWidth = max; } tableWidthFixed = true; } else if (initialTotalWidth <= max) { targetWidth = initialTotalWidth; } else if (null == tag.Parent || (null != tag.Parent && htmlPipelineContext.GetRootTags().Contains(tag.Parent.Name))) { targetWidth = max; } else /* this table is an inner table and width adjustment is done in outer table */ { targetWidth = GetTableWidth(columnWidths, outerWidth); } float totalFixedColumnWidth = GetTableWidth(fixedWidths, 0); float targetPercentage = 0; if (totalFixedColumnWidth == initialTotalWidth) // all column widths are fixed { targetPercentage = targetWidth / initialTotalWidth; if (initialTotalWidth > targetWidth) { for (int column = 0; column < columnWidths.Length; column++) { columnWidths[column] *= targetPercentage; } } else if (tableWidthFixed && targetPercentage != 1) { for (int column = 0; column < columnWidths.Length; column++) { columnWidths[column] *= targetPercentage; } } } else { targetPercentage = (targetWidth - totalFixedColumnWidth) / (initialTotalWidth - totalFixedColumnWidth); // Reduce width of columns if the columnWidth array + borders + // paddings // is too large for the given targetWidth. if (initialTotalWidth > targetWidth) { float leftToReduce = 0; for (int column = 0; column < columnWidths.Length; column++) { if (fixedWidths[column] == 0) { // Reduce width of the column to its targetWidth, if // widestWord of column still fits in the targetWidth of // the // column. if (widestWords[column] <= columnWidths[column] * targetPercentage) { columnWidths[column] *= targetPercentage; // else take the widest word and calculate space // left to // reduce. } else { columnWidths[column] = widestWords[column]; leftToReduce += widestWords[column] - columnWidths[column] * targetPercentage; } // if widestWord of a column does not fit in the // fixedWidth, // set the column width to the widestWord. } else if (fixedWidths[column] < widestWords[column]) { columnWidths[column] = widestWords[column]; leftToReduce += widestWords[column] - fixedWidths[column]; } } if (leftToReduce != 0) { // Reduce width of the column with the most text, if its // widestWord still fits in the reduced column. if (widestWords[indexOfLargestColumn] <= columnWidths[indexOfLargestColumn] - leftToReduce) { columnWidths[indexOfLargestColumn] -= leftToReduce; } else // set all columns to their minimum, with the // widestWord array. { for (int column = 0; leftToReduce != 0 && column < columnWidths.Length; column++) { if (fixedWidths[column] == 0 && columnWidths[column] > widestWords[column]) { float difference = columnWidths[column] - widestWords[column]; if (difference <= leftToReduce) { leftToReduce -= difference; columnWidths[column] = widestWords[column]; } else { columnWidths[column] -= leftToReduce; leftToReduce = 0; } } } if (leftToReduce != 0) { // If the table has an insufficient fixed width // by // an // attribute or style, try to enlarge the table // to // its // minimum width (= widestWords array). float pageWidth = GetHtmlPipelineContext(ctx).PageSize.Width; if (GetTableWidth(widestWords, outerWidth) < pageWidth) { targetWidth = GetTableWidth(widestWords, outerWidth); leftToReduce = 0; } else { // If all columnWidths are set to the // widestWordWidths and the table is still // to // wide // content will fall off the edge of a page, // which // is similar to HTML. targetWidth = pageWidth - outerWidth; leftToReduce = 0; } } } } // Enlarge width of columns to fit the targetWidth. } else if (initialTotalWidth < targetWidth) { for (int column = 0; column < columnWidths.Length; column++) { if (fixedWidths[column] == 0) { columnWidths[column] *= targetPercentage; } } } } try { table.SetTotalWidth(columnWidths); table.LockedWidth = true; table.DefaultCell.Border = Rectangle.NO_BORDER; } catch (DocumentException e) { throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e); } float?tableHeight = new HeightCalculator().GetHeight(tag, GetHtmlPipelineContext(ctx).PageSize.Height); int rowNumber = 0; foreach (TableRowElement row in tableRows) { int columnNumber = -1; float?computedRowHeight = null; if (tableHeight != null && tableRows.IndexOf(row) == tableRows.Count - 1) { float computedTableHeigt = table.CalculateHeights(); computedRowHeight = tableHeight - computedTableHeigt; } foreach (HtmlCell cell in row.Content) { IList <IElement> compositeElements = cell.CompositeElements; if (compositeElements != null) { foreach (IElement baseLevel in compositeElements) { if (baseLevel is PdfPTable) { TableStyleValues cellValues = cell.CellValues; float totalBordersWidth = cellValues.IsLastInRow ? styleValues.HorBorderSpacing * 2 : styleValues.HorBorderSpacing; totalBordersWidth += cellValues.BorderWidthLeft + cellValues.BorderWidthRight; float columnWidth = 0; for (int currentColumnNumber = columnNumber + 1; currentColumnNumber <= columnNumber + cell.Colspan; currentColumnNumber++) { columnWidth += columnWidths[currentColumnNumber]; } IPdfPTableEvent tableEvent = ((PdfPTable)baseLevel).TableEvent; TableStyleValues innerStyleValues = ((TableBorderEvent)tableEvent).TableStyleValues; totalBordersWidth += innerStyleValues.BorderWidthLeft; totalBordersWidth += innerStyleValues.BorderWidthRight; ((PdfPTable)baseLevel).TotalWidth = columnWidth - totalBordersWidth; } } } columnNumber += cell.Colspan; table.AddCell(cell); } table.CompleteRow(); if (computedRowHeight != null && computedRowHeight > 0) { float rowHeight = table.GetRow(rowNumber).MaxHeights; if (rowHeight < computedRowHeight) { table.GetRow(rowNumber).MaxHeights = computedRowHeight.Value; } } rowNumber++; } if (percentage) { table.WidthPercentage = utils.ParsePxInCmMmPcToPt(widthValue); table.LockedWidth = false; } List <IElement> elems = new List <IElement>(); if (invalidRowElements.Count > 0) { // all invalid row elements taken as caption int i = 0; Tag captionTag = tag.Children[i++]; while (!Util.EqualsIgnoreCase(captionTag.Name, HTML.Tag.CAPTION) && i < tag.Children.Count) { captionTag = tag.Children[i]; i++; } String captionSideValue; captionTag.CSS.TryGetValue(CSS.Property.CAPTION_SIDE, out captionSideValue); if (captionSideValue != null && Util.EqualsIgnoreCase(captionSideValue, CSS.Value.BOTTOM)) { elems.Add(table); elems.AddRange(invalidRowElements); } else { elems.AddRange(invalidRowElements); elems.Add(table); } } else { elems.Add(table); } return(elems); } catch (NoCustomContextException e) { throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e); } }
public void Excecute(string path, List <Label> list) { var doc = new Document(PageSize.A4, 0.5f, 0.5f, 0, 0); var output = new FileStream(path, FileMode.Create); var writer = PdfWriter.GetInstance(doc, output); Font labelBraceFont = FontFactory.GetFont("Verdana", 7f, Font.BOLD); doc.Open(); for (var i = 0; i < list.Count; i++) { if (i != 0 && i % 2 == 0) { doc.NewPage(); } var label = list[i]; PdfContentByte cb = writer.DirectContent; var imagePartNumberPDF417Code = GeneratePDF417BarCode(cb, label.Product.PartNumber + "P"); var table1 = new PdfPTable(2); table1.SpacingBefore = 0; if (i % 2 != 0) { table1.SpacingBefore = 15; } table1.DefaultCell.Border = 0; table1.WidthPercentage = 100; //table1.DefaultCell.FixedHeight = Heightfortable1; var cell11 = new PdfPCell(); cell11.Colspan = 1; var p = new Paragraph("(STABILIMENTO DI DESTINAZIONE)\r\nRECEIVER:", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SetLeading(0, 1.0f); cell11.AddElement(p); p = new Paragraph(label.Product.Receiver, FontFactory.GetFont("Helvetica", ReceiverFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, ReceiverLeading); cell11.VerticalAlignment = Element.ALIGN_LEFT; cell11.AddElement(p); table1.AddCell(cell11); var cell12 = new PdfPCell(); cell12.Colspan = 1; p = new Paragraph("(PUNTO DI RIFORNIMENTO)\r\nDOCK/GATE", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell12.AddElement(p); p = new Paragraph(label.Product.Dock, FontFactory.GetFont("Helvetica", DockGateFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, DockLeading); cell12.AddElement(p); cell12.VerticalAlignment = Element.ALIGN_LEFT; table1.AddCell(cell12); var cell21 = new PdfPCell(); p = new Paragraph("(NUMERO INTERNO B.A.M.)\r\nDOCUMENT NUMBER NO", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); Phrase r = new Phrase(" (N)", labelBraceFont); p.Add(r); p.SetLeading(0, 1.0f); cell21.AddElement(p); cell21.VerticalAlignment = Element.ALIGN_LEFT; cell21.Rowspan = 2; table1.AddCell(cell21); var innerTable = new PdfPTable(3); innerTable.DefaultCell.Border = 0; innerTable.WidthPercentage = 100; innerTable.DefaultCell.FixedHeight = 100f; var cell22_11 = new PdfPCell(); cell22_11.BorderWidthTop = 0; cell22_11.BorderWidthRight = 0; cell22_11.BorderWidthLeft = 0; cell22_11.BorderWidthBottom = 0; cell22_11.Colspan = 3; p = new Paragraph("(RAGIONE SOCIALE DEL FORNITORE)\r\nSUPPLIER ADDRESS", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell22_11.AddElement(p); p = new Paragraph(label.Product.SupplierAddress, FontFactory.GetFont("Helvetica", SupplierCompanyFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, SupplierAddressLeading); cell22_11.VerticalAlignment = Element.ALIGN_LEFT; cell22_11.AddElement(p); innerTable.AddCell(cell22_11); var cell22_21 = new PdfPCell(); cell22_21.Colspan = 1; p = new Paragraph("(MASSA NETTA)\r\nNET WT (kg)", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell22_21.AddElement(p); p = new Paragraph(label.Product.NetWeight, FontFactory.GetFont("Helvetica", GrossWeightAndBoxFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, NetLeading); cell22_21.VerticalAlignment = Element.ALIGN_LEFT; cell22_21.AddElement(p); innerTable.AddCell(cell22_21); var cell22_22 = new PdfPCell(); cell22_22.Colspan = 1; p = new Paragraph("(MASSA LORDA)\r\nGROSS WT (kg)", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell22_22.AddElement(p); p = new Paragraph(label.Product.GrossWeight, FontFactory.GetFont("Helvetica", GrossWeightAndBoxFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, NetLeading); cell22_22.VerticalAlignment = Element.ALIGN_LEFT; cell22_22.AddElement(p); innerTable.AddCell(cell22_22); var cell22_23 = new PdfPCell(); cell22_23.Colspan = 1; p = new Paragraph("(Q.TA CONTENITORI)\r\nNO BOXES", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell22_23.AddElement(p); p = new Paragraph(label.Product.Boxes, FontFactory.GetFont("Helvetica", GrossWeightAndBoxFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, NetLeading); cell22_23.VerticalAlignment = Element.ALIGN_LEFT; cell22_23.AddElement(p); innerTable.AddCell(cell22_23); var cell22 = new PdfPCell(innerTable); table1.AddCell(cell22); doc.Add(table1); var table2 = new PdfPTable(12); table2.DefaultCell.Border = 0; table2.WidthPercentage = 100.2f; //table2.DefaultCell.FixedHeight = Heightfortable2; var cell31 = new PdfPCell(); cell31.BorderWidthTop = 0; cell31.BorderWidthBottom = 0; cell31.Colspan = 7; cell31.Rowspan = 1; cell31.VerticalAlignment = Element.ALIGN_MIDDLE; p = new Paragraph("(NUMERO DISEGNO/SIMBOLO)\r\nPART NUMBER", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); r = new Phrase(" (P)", labelBraceFont); p.Add(r); p.IndentationLeft = -7f; p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell31.AddElement(p); cell31.PaddingLeft = 10; cell31.BorderWidthRight = 0; p = new Paragraph(label.Product.PartNumber, FontFactory.GetFont("Helvetica", PartNumberFontSize, BaseColor.BLACK)); p.IndentationLeft = -7; p.SpacingAfter = 10; p.SpacingBefore = 0; p.SetLeading(0, PartNumberLeading); cell31.VerticalAlignment = Element.ALIGN_LEFT; cell31.AddElement(p); table2.AddCell(cell31); var cell32 = new PdfPCell(); cell32.BorderWidthTop = 0; cell32.BorderWidthLeft = 0; cell32.BorderWidthRight = 0; cell32.BorderWidthBottom = 0; cell32.Colspan = 3; cell32.Rowspan = 1; cell32.PaddingTop = 25f; cell32.PaddingLeft = -25f; cell32.HorizontalAlignment = Element.ALIGN_LEFT; cell32.AddElement(imagePartNumberPDF417Code); var cell33 = new PdfPCell(); cell33.BorderWidthTop = 0; cell33.BorderWidthLeft = 0; cell33.BorderWidthBottom = 0; cell33.Colspan = 2; cell33.Rowspan = 1; cell33.PaddingTop = 22; Image logo = GenerateLogo(); logo.IndentationLeft = 5; logo.Alignment = Image.ALIGN_CENTER; cell33.AddElement(logo); table2.AddCell(cell32); table2.AddCell(cell33); doc.Add(table2); var table3 = new PdfPTable(2); table3.DefaultCell.Border = 0; table3.WidthPercentage = 100; //table3.DefaultCell.FixedHeight = Heightfortable3; var innerTable41 = new PdfPTable(2); var cell41_1 = new PdfPCell(); cell41_1.PaddingLeft = 10f; cell41_1.Colspan = 1; cell41_1.Rowspan = 1; cell41_1.BorderWidth = 0; p = new Paragraph("(QUANTITANEL CONTENITORE)\r\nQUANTITY", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); r = new Phrase(" (Q)", labelBraceFont); p.Add(r); p.IndentationLeft = -7f; p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell41_1.AddElement(p); p = new Paragraph(label.FixedQuantity, FontFactory.GetFont("Helvetica", QuantityFontSize, BaseColor.BLACK)); p.SpacingAfter = 10; p.SpacingBefore = 0; p.SetLeading(0, QuantityNumberLeading); cell41_1.AddElement(p); innerTable41.AddCell(cell41_1); var cell41_2 = new PdfPCell(); cell41_2.Colspan = 1; cell41_2.Rowspan = 1; cell41_2.BorderWidth = 0; innerTable41.AddCell(cell41_2); var cell41 = new PdfPCell(innerTable41); cell41.Colspan = 1; cell41.Rowspan = 1; table3.AddCell(cell41); var interTable42 = new PdfPTable(2); interTable42.DefaultCell.Border = 0; interTable42.WidthPercentage = 100; interTable42.DefaultCell.FixedHeight = 100f; var cell42_1 = new PdfPCell(); cell42_1.Colspan = 2; cell42_1.Rowspan = 1; p = new Paragraph("(DENOMINAZIONE DEL PRODOTTO)\r\nDESCRIPTION", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SetLeading(0, 1.0f); p.SpacingAfter = 0; p.SpacingBefore = 0; cell42_1.AddElement(p); p = new Paragraph(label.Product.Description, FontFactory.GetFont("Helvetica", DescriptionFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, DescriptionLeading); p.SpacingBefore = -3; cell42_1.VerticalAlignment = Element.ALIGN_LEFT; cell42_1.AddElement(p); interTable42.AddCell(cell42_1); var cell42_2 = new PdfPCell(); cell42_2.BorderWidthBottom = 0; cell42_2.BorderWidthRight = 0; cell42_2.BorderWidthLeft = 0; cell42_2.BorderWidthTop = 0; cell42_2.Colspan = 2; cell42_2.Rowspan = 2; p = new Paragraph("(DATI DI LOGISTICA)\r\nLOGISTIC REFERNCE", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell42_2.AddElement(p); p = new Paragraph(label.LogisticRefer, FontFactory.GetFont("Helvetica", LogisticsReferenceFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, LoginsticReferenceLeading); p.SpacingAfter = 0; cell42_2.VerticalAlignment = Element.ALIGN_LEFT; cell42_2.AddElement(p); interTable42.AddCell(cell42_2); var cell42_3 = new PdfPCell(); cell42_3.Colspan = 1; cell42_3.Rowspan = 1; p = new Paragraph("(DATA)\r\nDATE", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell42_3.AddElement(p); p = new Paragraph(label.Date, FontFactory.GetFont("Helvetica", ShipmentFontSize, BaseColor.BLACK)); p.SpacingAfter = 1; cell42_3.VerticalAlignment = Element.ALIGN_LEFT; p.SetLeading(0, DateLeading); cell42_3.AddElement(p); interTable42.AddCell(cell42_3); var cell42_32 = new PdfPCell(); cell42_32.Colspan = 1; cell42_32.Rowspan = 1; p = new Paragraph("(NUMERO DIMODIFICA)\r\nENGINERING CHANGE", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); cell42_32.AddElement(p); p = new Paragraph(label.Product.EngineeringChange, FontFactory.GetFont("Helvetica", ChangeNumberFontSize, BaseColor.BLACK)); p.SpacingAfter = 1; p.SetLeading(0, EngineerLeading); cell42_32.VerticalAlignment = Element.ALIGN_LEFT; cell42_32.AddElement(p); interTable42.AddCell(cell42_32); var cell42_4 = new PdfPCell(); cell42_4.BorderWidthBottom = 0; cell42_4.BorderWidthRight = 0; cell42_4.BorderWidthLeft = 0; cell42_4.BorderWidthTop = 0; cell42_4.Colspan = 2; cell42_4.Rowspan = 2; p = new Paragraph("(NUMERO LOTTO DI PRODUZIONE)\r\nBATCH NUMBER", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); r = new Phrase(" (H)", labelBraceFont); p.Add(r); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); p.IndentationLeft = 0f; cell42_4.AddElement(p); cell42_4.VerticalAlignment = Element.ALIGN_LEFT; p = new Paragraph("\r\n\r\n\r\n" + label.BatchNumber, FontFactory.GetFont("Helvetica", BatchNumberFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, 0.8f); p.IndentationLeft = 150f; cell42_4.VerticalAlignment = Element.ALIGN_MIDDLE; cell42_4.AddElement(p); interTable42.AddCell(cell42_4); var cell42 = new PdfPCell(interTable42); cell42.Colspan = 1; cell42.Rowspan = 2; table3.AddCell(cell42); var innerTableA = new PdfPTable(2); var innerTableA_Left = new PdfPTable(1); var A_Left_1 = new PdfPCell(); A_Left_1.Colspan = 1; A_Left_1.Rowspan = 1; p = new Paragraph("(CODICE FORNITORE)\r\nSUPPLIER CODE", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); r = new Phrase(" (V)", labelBraceFont); p.Add(r); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); A_Left_1.AddElement(p); p = new Paragraph("\r\n" + label.Product.SupplierCode, FontFactory.GetFont("Helvetica", SupplierCodeFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, SupplierLeading); A_Left_1.AddElement(p); innerTableA_Left.AddCell(A_Left_1); var A_Left_2 = new PdfPCell(); A_Left_2.Colspan = 1; A_Left_2.Rowspan = 1; p = new Paragraph("(NUMERO DELLA SCHEDA)\r\nSERIAL NUMBER", FontFactory.GetFont("Helvetica", TITLE_FONT_SIZE, BaseColor.BLACK)); r = new Phrase(" (S)/(M)", labelBraceFont); p.Add(r); p.SpacingAfter = 0; p.SpacingBefore = 0; p.SetLeading(0, 1.0f); A_Left_2.AddElement(p); p = new Paragraph("\r\n" + "S" + label.SerialNumber, FontFactory.GetFont("Helvetica", SerialNumberFontSize, BaseColor.BLACK)); p.SpacingAfter = 0; p.SetLeading(0, SerialNumberLeading); A_Left_2.AddElement(p); innerTableA_Left.AddCell(A_Left_2); var cellA_Left = new PdfPCell(innerTableA_Left); cellA_Left.Colspan = 1; cellA_Left.Rowspan = 1; var innerTableA_Right = new PdfPTable(1); var A_Right = new PdfPCell(); A_Right.Colspan = 1; A_Right.Rowspan = 1; Image im = GenerateQRCodeByLabel(label); im.Alignment = Image.ALIGN_CENTER; A_Right.HorizontalAlignment = Element.ALIGN_CENTER; A_Right.VerticalAlignment = Element.ALIGN_MIDDLE; A_Right.AddElement(im); innerTableA_Right.AddCell(A_Right); var cellA_Right = new PdfPCell(innerTableA_Right); cellA_Right.Colspan = 1; cellA_Right.Rowspan = 1; innerTableA.AddCell(cellA_Left); innerTableA.AddCell(cellA_Right); var cell51 = new PdfPCell(innerTableA); table3.AddCell(cell51); table3.CompleteRow(); doc.Add(table3); } doc.Close(); }
private void ReportHeader(Verhuren verhuur) { _fontstyle = FontFactory.GetFont("Tahoma", 11f, 1); _pdfCell = new PdfPCell(new Phrase("Aan:", _fontstyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("Van:", _fontstyle)); _pdfCell.Colspan = 1; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _fontstyle = FontFactory.GetFont("Tahoma", 11f, 0); _pdfCell = new PdfPCell(new Phrase(verhuur.Klanten.voornaam + " " + verhuur.Klanten.tussenvoegsel + " " + verhuur.Klanten.achternaam, _fontstyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("Autoverhuur Jansen", _fontstyle)); _pdfCell.Colspan = 1; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase(verhuur.Klanten.adres, _fontstyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("Patatlaan 21", _fontstyle)); _pdfCell.Colspan = 1; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase(verhuur.Klanten.postcode + " " + verhuur.Klanten.woonplaats, _fontstyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase("2490BS Den Haag", _fontstyle)); _pdfCell.Colspan = 1; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("Tel. 021 1234567", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("Web: www.lhhamming-001-site2.etempurl.com", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("Mail: [email protected]", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _fontstyle = FontFactory.GetFont("Tahoma", 11f, 1); _pdfCell = new PdfPCell(new Phrase("Factuurgegevens", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _fontstyle = FontFactory.GetFont("Tahoma", 11f, 0); _pdfCell = new PdfPCell(new Phrase("Factuurnummer: " + verhuur.VerhuurId, _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("Begindatum verhuur: " + verhuur.beginDatum.ToString().Remove(verhuur.beginDatum.ToString().Length - 9), _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("Eindddatum verhuur: " + verhuur.eindDatum.ToString().Remove(verhuur.eindDatum.ToString().Length - 9), _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n")); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n")); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase("\n", _fontstyle)); _pdfCell.Colspan = 4; _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT; _pdfCell.Border = 0; _pdfCell.BackgroundColor = BaseColor.WHITE; _pdfCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); }