public void RenderCanvasSheet(Stream stream, IEnumerable<CanvasItemModel> items, UserModel currentUser,UserModel requestedBy, PurchaseRequest Pr, string[] Vendors) { Document document = new Document(PageSize.LETTER); try { PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); // Create a page in the document and add it to the bottom layer document.NewPage(); //Pass Document to this CurrentDoc = document; page = writer.DirectContentUnder; page.BeginText(); int top = (int)document.GetTop(0); SetFontSizeTo(16); PrintText("CANVASS SHEET", 20, 10); SetFontSizeTo(10); //Header PrintText("Company Name: " + requestedBy.CompanyName, 20, 30); // Company Name PrintText("Department: " + requestedBy.DepartmentName, 20, 45); // Company Address PrintText("Purpose: " + Pr.Purpose, 20, 60); // Purpose PrintTextRight("Date: {0}".WithTokens(DateTime.Now.ToShortDateString()), 70, 30); // Date Created PrintTextRight("PR No: {0}".WithTokens(Pr.PRNo), 70, 45); // PR Number SetFontSizeTo(8); // START HERE ---------------------------- Paragraph Grid = new Paragraph("\n"); Grid.Alignment = 1; Grid.SpacingAfter = 10f; document.Add(Grid); Paragraph Grid2 = new Paragraph(); Grid2.Alignment = 1; Grid2.SpacingBefore = 35f; //Start Table ----------------------------------- PdfPTable rightTable = new PdfPTable(7); int[] widths = { 1, 7, 2, 2, 2, 2, 2 }; rightTable.SetWidths(widths); rightTable.TotalWidth = 570f; rightTable.LockedWidth = true; Font tableFont = new Font(Font.FontFamily.HELVETICA, 8); PdfPCell rightAlignedCell = new PdfPCell(); rightAlignedCell.HorizontalAlignment = Element.ALIGN_CENTER; //Headers rightAlignedCell.Phrase = new Phrase("Item No.", tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase("Item Description", tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase("Quantity", tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase("UOM", tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase(Vendors[0], tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase(Vendors[1], tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase(Vendors[2], tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.HorizontalAlignment = Element.ALIGN_RIGHT; foreach (var item in items) { string priceVendor1 = item.PriceVendor1 == 0 ? "NONE" : item.PriceVendor1.ToString(); string priceVendor2 = item.PriceVendor2 == 0 ? "NONE" : item.PriceVendor2.ToString(); string priceVendor3 = item.PriceVendor3 == 0 ? "NONE" : item.PriceVendor3.ToString(); rightTable.AddCell(new Phrase(item.ItemNumber.ToString(), tableFont)); rightTable.AddCell(new Phrase(item.ItemDescription, tableFont)); rightAlignedCell.Phrase = new Phrase(item.Quantity.ToString(), tableFont); rightTable.AddCell(rightAlignedCell); rightTable.AddCell(new Phrase(item.UOM, tableFont)); rightAlignedCell.Phrase = new Phrase(priceVendor1, tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase(priceVendor2, tableFont); rightTable.AddCell(rightAlignedCell); rightAlignedCell.Phrase = new Phrase(priceVendor3, tableFont); rightTable.AddCell(rightAlignedCell); } Grid2.Add(rightTable); document.Add(Grid2); // Footer SetFontSizeTo(10); PrintTextBottom("Requested By:", 20, 105); PrintTextBottom("{0} {1}".WithTokens(requestedBy.FirstName, requestedBy.LastName), 20, 35); PrintTextBottom("Prepared By:", 265, 105); PrintTextBottom("{0} {1}".WithTokens(currentUser.FirstName, currentUser.LastName), 265, 35); PrintTextBottom("Approved By:", 450, 105); PrintTextBottom("{0}".WithTokens("______________________"), 450, 35); page.EndText(); writer.Flush(); } finally { document.Close(); } }
public void RenderRfq(Stream stream, VendorModel vendor, IEnumerable<ItemModel> items, UserModel user, int RfqNumber, PurchaseRequest Pr, DateTime DateRequested) { Document document = new Document(PageSize.LETTER); try { PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); // Create a page in the document and add it to the bottom layer document.NewPage(); //Pass Document to this CurrentDoc = document; page = writer.DirectContentUnder; page.BeginText(); int top = (int)document.GetTop(0); SetFontSizeTo(16); PrintText("REQUEST FOR QUOTATION (THIS IS NOT AN ORDER)", 20, 10); SetFontSizeTo(10); //Header PrintText("Company Name: {0}".WithTokens(Pr.User.Company.Name), 20, 30); // Company Name PrintText("Address: 8th Floor Gedisco Tower, 534 Asuncion St., Binondo, Manila", 20, 45); // Company Address PrintText("Purchasing Department", 20, 60); PrintText("Issued By: {0} {1}".WithTokens(user.FirstName, user.LastName), 20, 75); // Requested By PrintTextRight("RFQ NO: {0}".WithTokens(RfqNumber), 70, 30); // RFQ Number PrintTextRight("Date: {0}".WithTokens(DateTime.Now.ToShortDateString()), 70, 45); // Date Created PrintTextRight("PR No: {0}".WithTokens(Pr.PRNo), 70, 60); // PR Number //Body SetFontSizeTo(14); PrintText("BID/OFFER/QUOTE MUST BE RECEIVED BY:", 20, 105); // Requested By PrintTextRight("Date: {0}".WithTokens(DateRequested.ToShortDateString()), 95, 105); // Date Required SetFontSizeTo(10); PrintText("Attention: {0} {1}".WithTokens(user.FirstName, user.LastName), 40, 125); // Vendor Contact Person PrintText("Tel No: {0}".WithTokens("+63 2 244 9296"), 40, 140); // Vendor Tel No PrintText("Email Address: {0}".WithTokens(user.Email), 40, 155); // Vendor Email PrintText("Fax No: {0}".WithTokens("+63 2 241 7826"), 240, 125); // Vendor Fax No SetFontSizeTo(8); PrintText("Unless otherwise requested, quote on each item separately. Unit Prices shall be shown. If unable to furnish", 20, 175); // Vendor Email PrintText("items as specified, submit sample and/or descriptive specifications of substitute offered.", 20, 185); // Vendor Email //Items SetFontSizeTo(8); PrintText("_______________________________________________________________________________________________________________________", 20, 210); PrintText("Item No.", 20, 205); PrintText("Item Description", 70, 205); PrintText("Quantity", 370, 205); PrintText("Unit Price", 420, 205); PrintText("Discount", 470, 205); PrintText("Total", 520, 205); //// Items.. //int staryY = 225; //int itemCount = 1; //foreach (var item in items) { // PrintItem(itemCount.ToString(), item.Description, item.Quantity.ToString(), ref staryY); // itemCount++; //} //PrintText("********** NOTHING FOLLOWS **********", 75, staryY + 15); // START HERE ---------------------------- Paragraph Grid = new Paragraph("\n\n\n\n\n\n\n\n\n"); Grid.Alignment = 1; Grid.SpacingAfter = 35f; document.Add(Grid); Paragraph Grid2 = new Paragraph(); Grid2.Alignment = 1; Grid2.SpacingBefore = 35f; //Start Table ----------------------------------- PdfPTable rightTable = new PdfPTable(7); int[] widths = { 1, 1, 1, 7, 2, 2, 2 }; rightTable.SetWidths(widths); rightTable.TotalWidth = 570f; rightTable.LockedWidth = true; Font tableFont = new Font(Font.FontFamily.HELVETICA, 8); rightTable.HorizontalAlignment = Element.ALIGN_CENTER; rightTable.AddCell(new Phrase("Item No.", tableFont)); rightTable.AddCell(new Phrase("Item Description", tableFont)); rightTable.AddCell(new Phrase("Quantity", tableFont)); rightTable.AddCell(new Phrase("Unit Price", tableFont)); rightTable.AddCell(new Phrase("Discount", tableFont)); rightTable.AddCell(new Phrase("Total Amount", tableFont)); rightTable.HorizontalAlignment = Element.ALIGN_LEFT; int itemCount = 1; foreach (var item in items) { rightTable.AddCell(new Phrase(item.ItemNumber.ToString(), tableFont)); rightTable.AddCell(new Phrase(item.Description, tableFont)); rightTable.AddCell(new Phrase(item.Quantity.ToString(), tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); itemCount++; } //Nothing Follows rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("******** NOTHING FOLLOWS ********", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); Grid2.Add(rightTable); document.Add(Grid2); // End of table ----------------------------------- // Footer SetFontSizeTo(10); PrintTextBottom("If accepted within _____ days, the undersigned offers and agrees to honor this quotation.", 20, 85); PrintTextBottom("Print Name of Person:", 20, 65); PrintTextBottom("Company Name:", 20, 50); PrintTextBottom("Address:", 20, 35); PrintTextBottom("Email Address:", 20, 20); PrintTextBottom("No. of Days to Deliver:", 200, 65); PrintTextBottom("Telephone No.:", 200, 50); PrintTextBottom("Fax No.:", 200, 35); page.EndText(); writer.Flush(); } finally { document.Close(); } }
private void CreateReport(string filePath) { AppFileTemplate f = (AppFileTemplate)DataContext; // margins float left = 30; float right = 10; float top = 10; float bottom = 10; float headH = 20; float indent = 5; //string fontName = "C:\\WINDOWS\\FONTS\\CALIBRI.TTF"; string fontName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "CALIBRI.TTF"); iText.Font NormalSatirFont = iText.FontFactory.GetFont(fontName, "CP1254", 10, iText.Font.NORMAL); iText.Font BoldSatirFont = iText.FontFactory.GetFont(fontName, "CP1254", 10, iText.Font.BOLD); iText.Font NormalRiseFont = iText.FontFactory.GetFont(fontName, "CP1254", 8, iText.Font.NORMAL); iText.Font NormalSymbolFont = iText.FontFactory.GetFont(iText.FontFactory.SYMBOL, 10, iText.Font.NORMAL); iText.Document doc = new iText.Document(iText.PageSize.A4, left, right, top, bottom); float xLL = doc.GetLeft(left); float yLL = doc.GetBottom(bottom); float xUR = doc.GetRight(right); float yUR = doc.GetTop(top); float w = xUR - xLL; float h = yUR - yLL; float xUL = xLL; float yUL = yUR; float xLR = xUR; float yLR = yLL; //float graphW = w - 10; //float graphH = graphW * 2 / 3; float graphH = 3 * h / 5; float graphW = w - 10; PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(filePath, FileMode.Create)); doc.Open(); // direct content PdfContentByte cb = writer.DirectContent; // çizgiler DrawLine(cb, xUR - w, yUR, xUR, yUR); DrawLine(cb, xUR - w, yUR, xLL, yLL); DrawLine(cb, xLL, yLL, xLL + w, yLL); DrawLine(cb, xLL + w, yLL, xUR, yUR); DrawLine(cb, xUL, yUL - headH, xUR, yUR - headH); DrawLine(cb, xUL, yUL - headH - graphH, xUR, yUR - headH - graphH); // başlık ColumnText ct = new ColumnText(cb); ct.Indent = indent; iText.Phrase txt = new iText.Phrase(); txt.Add(new iText.Chunk(f.ReportTitle, NormalSatirFont)); ct.SetSimpleColumn(txt, xUL, yUL - headH, xUR, yUR, headH / 1.5f, iText.Element.ALIGN_LEFT | iText.Element.ALIGN_MIDDLE); ct.Go(); var stream = new MemoryStream(); var pngExporter = new PngExporter { Width = (int)graphW, Height = (int)graphH, Background = OxyColors.White }; pngExporter.Export(PlotView.Model, stream); iText.Image png = iText.Image.GetInstance(stream.GetBuffer()); png.Alignment = iText.Element.ALIGN_CENTER | iText.Element.ALIGN_MIDDLE; png.SetAbsolutePosition(xUL, yUL - headH - graphH); doc.Add(png); float kstW = w / 2; float kstH = (h - headH - graphH) / 1.5f; ColumnText ctKesit = new ColumnText(cb); ctKesit.Indent = indent; txt = new iText.Phrase(); txt.Add(new iText.Chunk("Kesit\n", BoldSatirFont)); txt.Add(new iText.Chunk(String.Format("Genişlik, b = {0:0} cm\n", f.b), NormalSatirFont)); txt.Add(new iText.Chunk(String.Format("Yükseklik, h = {0:0} cm\n", f.h), NormalSatirFont)); txt.Add(new iText.Chunk(String.Format("Alan, bxh = {0:0} cm²\n", f.b * f.h), NormalSatirFont)); txt.Add(new iText.Chunk("\nMalzeme\n", BoldSatirFont)); txt.Add(new iText.Chunk("f", NormalSatirFont)); txt.Add(new iText.Chunk("c", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa ", f.Beton().fc.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("f", NormalSatirFont)); txt.Add(new iText.Chunk("y", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa\n", f.DonatiCeligi().fy.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("f", NormalSatirFont)); txt.Add(new iText.Chunk("cd", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa ", f.Beton().fcd.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("f", NormalSatirFont)); txt.Add(new iText.Chunk("yd", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa\n", f.DonatiCeligi().fyd.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("E", NormalSatirFont)); txt.Add(new iText.Chunk("c", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa ", f.Beton().E.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("E", NormalSatirFont)); txt.Add(new iText.Chunk("s", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0} MPa\n", f.DonatiCeligi().E.TonnesForcePerSquareMeter().Megapascals), NormalSatirFont)); txt.Add(new iText.Chunk("e", NormalSymbolFont)); txt.Add(new iText.Chunk("cu", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0.0000} m/m ", f.Beton().Ecu), NormalSatirFont)); txt.Add(new iText.Chunk("e", NormalSymbolFont)); txt.Add(new iText.Chunk("yd", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0.00000} m/m\n", f.DonatiCeligi().Eyd), NormalSatirFont)); txt.Add(new iText.Chunk("k", NormalSatirFont)); txt.Add(new iText.Chunk("1", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(String.Format(" = {0:0.000}\n", f.Beton().k1), NormalSatirFont)); ctKesit.SetSimpleColumn(txt, xUL, yUL - headH - graphH - kstH, xUL + kstW, yUL - headH - graphH, 15, iText.Element.ALIGN_LEFT); ctKesit.Go(); ColumnText ctDonati = new ColumnText(cb); txt = new iText.Phrase(); txt.Add(new iText.Chunk("Donatı\n", BoldSatirFont)); int j = 1; foreach (var rb in f.ReinforcingBars) { txt.Add(new iText.Chunk("A", NormalSatirFont)); txt.Add(new iText.Chunk(string.Format("s{0}", j), NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format("={0:0.00} cm², ", rb.As), NormalSatirFont)); txt.Add(new iText.Chunk("d", NormalSatirFont)); txt.Add(new iText.Chunk(string.Format("{0}", j), NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format("={0:0.00} cm\n", rb.di), NormalSatirFont)); j++; } txt.Add(new iText.Chunk("r", NormalSymbolFont)); txt.Add(new iText.Chunk(string.Format("=%{0:0.00}\n", 100.0 * f.ReinforcingBars.Sum(i => i.As) / (f.b * f.h)), NormalSatirFont)); txt.Add(new iText.Chunk("(d", NormalSatirFont)); txt.Add(new iText.Chunk("i", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(":Kesit basınç yüzeyinin donatı eksenine uzaklığı)\n", NormalSatirFont)); txt.Add(new iText.Chunk("\nDayanım Azaltma Katsayıları\n", BoldSatirFont)); txt.Add(new iText.Chunk("f", NormalSymbolFont)); txt.Add(new iText.Chunk("a", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00}, ", f.PhiA), NormalSatirFont)); txt.Add(new iText.Chunk("f", NormalSymbolFont)); txt.Add(new iText.Chunk("b", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00}, ", f.PhiB), NormalSatirFont)); txt.Add(new iText.Chunk("f", NormalSymbolFont)); txt.Add(new iText.Chunk("c", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00}", f.PhiC), NormalSatirFont)); //txt.Add(new iText.Chunk("\n\nTasarım:\n", BoldSatirFont)); //txt.Add(new iText.Chunk(f.Code.ToString(), NormalSatirFont)); ctDonati.SetSimpleColumn(txt, xUL + kstW, yUL - headH - graphH - kstH, xUL + 2 * kstW, yUL - headH - graphH, 15, iText.Element.ALIGN_LEFT); ctDonati.Go(); ColumnText ctTesir = new ColumnText(cb); ctTesir.Indent = indent; txt = new iText.Phrase(); txt.Add(new iText.Chunk("Maksimum eksenel basınç, N", NormalSatirFont)); txt.Add(new iText.Chunk("max", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00} t\n", f.Pmax), NormalSatirFont)); txt.Add(new iText.Chunk("Maksimum eksenel çekme, N", NormalSatirFont)); txt.Add(new iText.Chunk("min", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00} t\n\n", f.Pmin), NormalSatirFont)); txt.Add(new iText.Chunk("Yönetmelik maksimum eksenel basınç sınırı, N", NormalSatirFont)); txt.Add(new iText.Chunk("max", NormalRiseFont).SetTextRise(-1.0f)); txt.Add(new iText.Chunk(string.Format(" = {0:0.00} t", f.ActualPmax), NormalSatirFont)); ctTesir.SetSimpleColumn(txt, xUL, yUL - headH - graphH - 1.5f * kstH, xUL + kstW, yUL - headH - graphH - kstH, 15, iText.Element.ALIGN_LEFT); ctTesir.Go(); doc.Close(); }
public void RenderPurchaseOrder(Stream stream, int PoNumber, IEnumerable<PoItemModel> PoItems, int RequestNumber, string VendorName, string VendorCode, string VendorAddress, DateTime DateCreated, DateTime DeliveryDate, UserModel RequestUser, UserModel CurrentUser) { Document document = new Document(PageSize.LETTER); try { PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); // Create a page in the document and add it to the bottom layer document.NewPage(); //Pass Document to this CurrentDoc = document; string logoLocation = sonicLogo; float logoPosition = 50; string CurrentCompany = RequestUser.CompanyName; //Image if (RequestUser.CompanyId == (int)CompanyIds.SonicSteel) { logoLocation = sonicLogo; logoPosition = 70; } else if (RequestUser.CompanyId == (int)CompanyIds.SteelTech) { logoLocation = steeltechLogo; } else if (RequestUser.CompanyId == (int)CompanyIds.Somico) { logoLocation = somicoLogo; } Image logo = Image.GetInstance(Directory.GetCurrentDirectory() + logoLocation); logo.SetAbsolutePosition(20, (int)CurrentDoc.GetTop(logoPosition)); // START HERE ---------------------------- Paragraph Grid = new Paragraph("\n\n\n\n\n\n\n\n\n"); Grid.Alignment = 1; Grid.SpacingAfter = 35f; document.Add(Grid); Paragraph Grid2 = new Paragraph(); Grid2.Alignment = 1; Grid2.SpacingBefore = 35f; //Start Table ----------------------------------- PdfPTable rightTable = new PdfPTable(7); int[] widths = { 1, 1, 1, 7, 2, 2, 2 }; rightTable.SetWidths(widths); rightTable.TotalWidth = 570f; rightTable.LockedWidth = true; Font tableFont = new Font(Font.FontFamily.HELVETICA, 8); rightTable.HorizontalAlignment = Element.ALIGN_CENTER; rightTable.AddCell(new Phrase("Item No.", tableFont)); rightTable.AddCell(new Phrase("Quantity", tableFont)); rightTable.AddCell(new Phrase("UOM", tableFont)); rightTable.AddCell(new Phrase("Item Description", tableFont)); rightTable.AddCell(new Phrase("Unit Price", tableFont)); rightTable.AddCell(new Phrase("Discount", tableFont)); rightTable.AddCell(new Phrase("Total Amount", tableFont)); rightTable.HorizontalAlignment = Element.ALIGN_LEFT; int itemCount = 1; foreach (var poItem in PoItems) { rightTable.AddCell(new Phrase(itemCount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Quantity.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.UOM, tableFont)); rightTable.AddCell(new Phrase(poItem.Description, tableFont)); rightTable.AddCell(new Phrase(poItem.Price.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Discount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.TotalPrice.ToString(), tableFont)); itemCount++; } //Nothing Follows rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("******** NOTHING FOLLOWS ********", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); //Grand Total rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("Grand Total:", new Font(Font.FontFamily.HELVETICA, 12))); rightTable.AddCell(new Phrase(PoItems.Sum(x => x.TotalPrice).ToString(), new Font(Font.FontFamily.HELVETICA, 12))); Grid2.Add(rightTable); document.Add(Grid2); // End of table ----------------------------------- page = writer.DirectContentUnder; page.AddImage(logo); page.Stroke(); // For "Purchase Order" Text PrintRectangle(20, 120, 570, 50); //For two tables PrintRectangle(20, 230, 350, 100); PrintRectangle(370, 230, 220, 100); //For Footer PrintRectangleBottom(20, 20, 570, 50); page.BeginText(); SetFontSizeTo(24); PrintText("PURCHASE ORDER", 180, 105); SetPOCompanyHeader(RequestUser); SetFontSizeTo(10); // Header PrintText("To:", 25, 140); // Vendor Name SetFontSizeTo(8); PrintText(VendorName, 40, 140); // Vendor Name SetFontSizeTo(7); PrintText(VendorAddress, 25, 155); // Vendor Address SetFontSizeTo(10); PrintText("Vendor Code: " + VendorCode, 25, 220); // Venodr Id PrintText("PO Number: " + PoNumber, 375, 140); // Vendor Name PrintText("PO Date: " + DateTime.Now.ToShortDateString(), 375, 160); // Date Now PrintText("PR Number: " + RequestNumber, 375, 180); // Request Number PrintText("Delivery Date: " + DeliveryDate.ToShortDateString(), 375, 220); // Delivery Date //Footer SetFontSizeTo(8); PrintTextBottom("Purchase Orders are not valid unless signed by the Authorized Signatories. " + CurrentCompany + " will not recognize claims ", 20, 130); PrintTextBottom("based on verbal orders. If delivery is not made by the date indicated in this Purchase Order, United Steel Technology International Corporation may cancel this ", 20, 115); PrintTextBottom("Purchase Order, without any liability whatsoever. Seller expressly warrants that all goods or services furnished under this agreement shall conform to all ", 20, 100); PrintTextBottom("specifications and appropriate standards, will be new and will be free from defects in material or workmanship.", 20, 85); PrintTextBottom("Prepared By:", 25, 55); PrintTextBottom(CurrentUser.FirstName + " " + CurrentUser.LastName, 25, 30); PrintTextBottom("Noted By:", 255, 55); PrintTextBottom("Approved By:", 450, 55); //PrintTextBottom("No. of Days to Deliver:", 200, 65); //PrintTextBottom("Telephone No.:", 200, 50); //PrintTextBottom("Fax No.:", 200, 35); page.EndText(); writer.Flush(); } finally { document.Close(); } }
/*Evento que ocurre antes de pasar a una nueva página en el documento. Se utiliza para insertar el pie de página.*/ public override void OnEndPage(iTextSharp.text.pdf.PdfWriter writer, iTextSharp.text.Document document) { base.OnEndPage(writer, document); string pathWater = string.Empty; string nota_pie = string.Empty; float anchoWater = 0; float heightWater = 0; PdfPCell cell = null; PdfPRow row = null; Image img = null; float escalaW = 0; string pathAcreimg = string.Empty; float escalaH = 0; float escalaAcreW = 0; float escalaAcreH = 0; string subcontrata = string.Empty; string url_informe = string.Empty; int pageN = writer.PageNumber; Rectangle nroTotal = document.PageSize; var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11); iTextSharp.text.Font normal = FontFactory.GetFont(FontFactory.HELVETICA, 6); iTextSharp.text.Font bold = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8); JArray data = JArray.Parse(parametro); Paragraph p; if (lmr) { //listcells = new List<PdfPCell>(); pathImg = data[0]["logo"].ToString(); escalaW = (float)data[0]["escalaWidthLogo"]; escalaH = (float)data[0]["escalaHeightLogo"]; pathWater = data[0]["logoWater"].ToString(); anchoWater = (float)data[0]["escalaWidthLogoWater"]; heightWater = (float)data[0]["escalaHeightLogoWater"]; subTitulo = data[0]["titulo_lmr"].ToString(); footer_txt = data[0]["footer"].ToString(); WriteWaterMark(document, pathWater, anchoWater, heightWater); float[] head = { 98, 325, 100 }; PdfPTable tblTableTitulo = new PdfPTable(head.Length); tblTableTitulo.TotalWidth = document.PageSize.Width; tblTableTitulo.WidthPercentage = 100; tblTableTitulo.SetWidths(head); tblTableTitulo.DefaultCell.Border = Rectangle.NO_BORDER; //creo la imagen de bureau cell = new PdfPCell(new Paragraph("")); img = Image.GetInstance(urlBase + pathImg); img.ScaleAbsolute(escalaW, escalaH); cell.AddElement(img); cell.Border = 0; tblTableTitulo.AddCell(cell); //creo el titulo cell = new PdfPCell(new Paragraph(new Chunk(titulo, boldFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.PaddingTop = 13; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); //listcells = new List<PdfPCell>(); cell = new PdfPCell(new Phrase("")); cell.Border = 0; tblTableTitulo.AddCell(cell); cell = new PdfPCell(new Paragraph(new Chunk(subTitulo))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Top = 100; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); tblTableTitulo.WriteSelectedRows(0, -1, 20, writer.PageSize.GetTop(document.TopMargin) + 140, writer.DirectContent); //número de páginas String str = "Página " + pageN.ToString() + " / "; cb.SetRGBColorFill(100, 100, 100); cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 8); //agrega el rotulo //cb.SetTextMatrix(document.PageSize.Width - document.RightMargin - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.SetTextMatrix(document.PageSize.Width - 50 - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.ShowText(str); cb.EndText(); //agrega el total de paginas //cb.AddTemplate(template, document.PageSize.Width - document.RightMargin - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); cb.AddTemplate(template, document.PageSize.Width - 50 - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); float[] cabecera = { 350, 78 }; PdfPTable pdfTab = new PdfPTable(cabecera.Length); pdfTab.TotalWidth = document.PageSize.Width; pdfTab.WidthPercentage = 100; pdfTab.SetWidths(cabecera); pdfTab.DefaultCell.Border = Rectangle.NO_BORDER; Chunk footer = new Chunk(footer_txt, bold); Chunk Subfooter = new Chunk("Information based on: https://globalmrl.com" + "\nThe results of this analysis refer only to the materials subjected to the analysis.\n" + "This analysis result can not be reproduced in whole or in part without the express authorization of Inspectorate Services Perú S.A.C.\n" + "There is no responsibility on the part of Inspectorate Services Perú S.A.C. in relation to the Data Review provided\n", normal); //byte[] b = IronBarCode.QRCodeWriter.CreateQrCode("https://app.bureauveritas.com.pe/agrifood_test/", 50, IronBarCode.QRCodeWriter.QrErrorCorrectionLevel.Medium).ToPngBinaryData(); //Image imgs = Image.GetInstance(b); //List<PdfPCell> listCells = new List<PdfPCell>(); cell = new PdfPCell(new Paragraph(Subfooter)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); pdfTab.CompleteRow(); cell = new PdfPCell(new Paragraph(footer)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); //imagen de codigo de barras cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); pdfTab.CompleteRow(); pdfTab.WriteSelectedRows(0, -1, 50, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); } if (arfd) { //listcells = new List<PdfPCell>(); pathImg = data[0]["logo"].ToString(); escalaW = (float)data[0]["escalaWidthLogo"]; escalaH = (float)data[0]["escalaHeightLogo"]; pathWater = data[0]["logoWater"].ToString(); anchoWater = (float)data[0]["escalaWidthLogoWater"]; heightWater = (float)data[0]["escalaHeightLogoWater"]; subTitulo = data[0]["titulo_arfd"].ToString(); footer_txt = data[0]["footer"].ToString(); WriteWaterMark(document, pathWater, anchoWater, heightWater); float[] head = { 98, 325, 100 }; PdfPTable tblTableTitulo = new PdfPTable(head.Length); tblTableTitulo.TotalWidth = document.PageSize.Width; tblTableTitulo.WidthPercentage = 100; tblTableTitulo.SetWidths(head); tblTableTitulo.DefaultCell.Border = Rectangle.NO_BORDER; //creo la imagen de bureau cell = new PdfPCell(new Paragraph("")); img = Image.GetInstance(urlBase + pathImg); img.ScaleAbsolute(escalaW, escalaH); cell.AddElement(img); cell.Border = 0; tblTableTitulo.AddCell(cell); //creo el titulo cell = new PdfPCell(new Paragraph(new Chunk(titulo, boldFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.PaddingTop = 13; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); //listcells = new List<PdfPCell>(); cell = new PdfPCell(new Phrase("")); cell.Border = 0; tblTableTitulo.AddCell(cell); cell = new PdfPCell(new Paragraph(new Chunk(subTitulo))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Top = 100; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); tblTableTitulo.WriteSelectedRows(0, -1, 20, writer.PageSize.GetTop(document.TopMargin) + 140, writer.DirectContent); //número de páginas String str = "Página " + pageN.ToString() + " / "; cb.SetRGBColorFill(100, 100, 100); cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 8); //agrega el rotulo //cb.SetTextMatrix(document.PageSize.Width - document.RightMargin - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.SetTextMatrix(document.PageSize.Width - 50 - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.ShowText(str); cb.EndText(); //agrega el total de paginas //cb.AddTemplate(template, document.PageSize.Width - document.RightMargin - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); cb.AddTemplate(template, document.PageSize.Width - 50 - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); float[] cabecera = { 350, 78 }; PdfPTable pdfTab = new PdfPTable(cabecera.Length); pdfTab.TotalWidth = document.PageSize.Width; pdfTab.WidthPercentage = 100; pdfTab.SetWidths(cabecera); pdfTab.DefaultCell.Border = Rectangle.NO_BORDER; Chunk footer = new Chunk(footer_txt, bold); //Chunk footer = new Chunk("Av. Elmer Faucett N° 444. distrito del Callao, Provincia Constitucional del Callao - Perú\n Central: (511) 613 - 8080 / www.bureauveritas.com", bold); Chunk Subfooter = new Chunk("Los resultados presentados corresponden sólo a la muestra indicada." + "\nLos resultados de este análisis se refieren únicamente a las materias sometidas al análisis.\n" + "Este resultado de análisis no puede ser reproducido total o parcialmente sin la autorización expresa de Inspectorate Service Perú S.A.C\n" + "No existe ninguna responsabilidad por parte de Inspectorate Service Perú S.A.C\n" + "en relación proporcionada respecto a los valores cuantificados inferiores al LC.", normal); //byte[] b = IronBarCode.QRCodeWriter.CreateQrCode("https://app.bureauveritas.com.pe/agrifood_test/", 50, IronBarCode.QRCodeWriter.QrErrorCorrectionLevel.Medium).ToPngBinaryData(); //Image imgs = Image.GetInstance(b); //List<PdfPCell> listCells = new List<PdfPCell>(); cell = new PdfPCell(new Paragraph(Subfooter)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); //PdfPRow row = new Pd pdfTab.CompleteRow(); cell = new PdfPCell(new Paragraph(footer)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); //imagen de codigo de barras cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); pdfTab.CompleteRow(); //pdfTab.WriteSelectedRows(0, -1, document.LeftMargin, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); pdfTab.WriteSelectedRows(0, -1, 50, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); } if (traza) { //listcells = new List<PdfPCell>(); pathImg = data[0]["logo"].ToString(); escalaW = (float)data[0]["escalaWidthLogo"]; escalaH = (float)data[0]["escalaHeightLogo"]; pathWater = data[0]["logoWater"].ToString(); anchoWater = (float)data[0]["escalaWidthLogoWater"]; heightWater = (float)data[0]["escalaHeightLogoWater"]; subTitulo = data[0]["titulo_traza"].ToString(); footer_txt = data[0]["footer"].ToString(); WriteWaterMark(document, pathWater, anchoWater, heightWater); float[] head = { 98, 325, 100 }; PdfPTable tblTableTitulo = new PdfPTable(head.Length); tblTableTitulo.TotalWidth = document.PageSize.Width; tblTableTitulo.WidthPercentage = 100; tblTableTitulo.SetWidths(head); tblTableTitulo.DefaultCell.Border = Rectangle.NO_BORDER; //creo la imagen de bureau cell = new PdfPCell(new Paragraph("")); img = Image.GetInstance(urlBase + pathImg); img.ScaleAbsolute(escalaW, escalaH); cell.AddElement(img); cell.Border = 0; tblTableTitulo.AddCell(cell); //listcells.Add(cell); //creo el titulo cell = new PdfPCell(new Paragraph(new Chunk(titulo, boldFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.PaddingTop = 13; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); //listcells = new List<PdfPCell>(); cell = new PdfPCell(new Phrase("")); cell.Border = 0; tblTableTitulo.AddCell(cell); cell = new PdfPCell(new Paragraph(new Chunk(subTitulo))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Top = 100; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.Border = 0; tblTableTitulo.AddCell(cell); tblTableTitulo.CompleteRow(); tblTableTitulo.WriteSelectedRows(0, -1, 20, writer.PageSize.GetTop(document.TopMargin) + 140, writer.DirectContent); //número de páginas String str = "Página " + pageN.ToString() + " / "; cb.SetRGBColorFill(100, 100, 100); cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 8); //agrega el rotulo //cb.SetTextMatrix(document.PageSize.Width - document.RightMargin - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.SetTextMatrix(document.PageSize.Width - 50 - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.ShowText(str); cb.EndText(); //agrega el total de paginas //cb.AddTemplate(template, document.PageSize.Width - document.RightMargin - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); cb.AddTemplate(template, document.PageSize.Width - 50 - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); float[] cabecera = { 350, 78 }; PdfPTable pdfTab = new PdfPTable(cabecera.Length); pdfTab.TotalWidth = document.PageSize.Width; pdfTab.WidthPercentage = 100; pdfTab.SetWidths(cabecera); pdfTab.DefaultCell.Border = Rectangle.NO_BORDER; Chunk footer = new Chunk(footer_txt, bold); Chunk Subfooter = new Chunk("Los resultados presentados corresponden sólo a la muestra indicada." + "\nLos resultados de este análisis se refieren únicamente a las materias sometidas al análisis.\n" + "Este resultado de análisis no puede ser reproducido total o parcialmente sin la autorización expresa de Inspectorate Service Perú S.A.C\n" + "No existe ninguna responsabilidad por parte de Inspectorate Service Perú S.A.C\n" + "en relación proporcionada respecto a los valores cuantificados inferiores al LC.", normal); //byte[] b = IronBarCode.QRCodeWriter.CreateQrCode("https://app.bureauveritas.com.pe/agrifood_test/", 50, IronBarCode.QRCodeWriter.QrErrorCorrectionLevel.Medium).ToPngBinaryData(); //Image imgs = Image.GetInstance(b); List <PdfPCell> listCells = new List <PdfPCell>(); cell = new PdfPCell(new Paragraph(Subfooter)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); //PdfPRow row = new Pd pdfTab.CompleteRow(); cell = new PdfPCell(new Paragraph(footer)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); //imagen de codigo de barras cell = new PdfPCell(new Paragraph("")); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.PaddingTop = 5; cell.Border = 0; pdfTab.AddCell(cell); pdfTab.CompleteRow(); //pdfTab.WriteSelectedRows(0, -1, document.LeftMargin, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); pdfTab.WriteSelectedRows(0, -1, 50, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); } if (informe) { Rectangle re = new Rectangle(0, 0, 13, document.GetTop(document.TopMargin) + 350); re.BackgroundColor = custom; try { PdfContentByte under = writer.DirectContentUnder; under.BeginText(); under.EndText(); under.Rectangle(re); under.Stroke(); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } //número de páginas String str = "Página " + pageN.ToString() + " / "; //float len = this.RunDateFont.BaseFont.GetWidthPoint(text, this.RunDateFont.Size); cb.SetRGBColorFill(100, 100, 100); cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 8); //agrega el rotulo //cb.SetTextMatrix(document.PageSize.Width - document.RightMargin - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.SetTextMatrix(document.PageSize.Width - 50 - str.Length - template.Width, document.PageSize.GetTop(document.TopMargin) + 10); cb.ShowText(str); cb.EndText(); //agrega el total de paginas //cb.AddTemplate(template, document.PageSize.Width - document.RightMargin - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); cb.AddTemplate(template, document.PageSize.Width - 50 - str.Length - 10, document.PageSize.GetTop(document.TopMargin) + 10); //escribe cabecera float tot = document.LeftMargin + document.RightMargin; float[] head = { 50, 180, 100 }; PdfPTable tblTableTitulo = new PdfPTable(head.Length); tblTableTitulo.TotalWidth = document.PageSize.Width; tblTableTitulo.WidthPercentage = 100; tblTableTitulo.SetWidths(head); //seteo una lista de celdas //listcells = new List<PdfPCell>(); pathImg = data[0]["logo"].ToString(); escalaW = (float)data[0]["escalaWidthLogo"]; escalaH = (float)data[0]["escalaHeightLogo"]; pathWater = data[0]["logoWater"].ToString(); anchoWater = (float)data[0]["escalaWidthLogoWater"]; heightWater = (float)data[0]["escalaHeightLogoWater"]; footer_txt = data[0]["footer"].ToString(); subcontrata = data[0]["subcontrata"].ToString(); nota_pie = data[0]["notas_pie"].ToString(); url_informe = data[0]["url_informe"].ToString(); //agrego el sello de agua WriteWaterMark(document, pathWater, anchoWater, heightWater); if (data[0]["acreditacion"] != null) { foreach (JObject jObject in data[0]["acreditacion"].Children <JToken>()) { titulo = jObject["cabecera_informe"].ToString(); subTitulo = jObject["titulo_informe"].ToString(); } } else { titulo = data[0]["titulo_default"].ToString(); subTitulo = data[0]["subtitulo_default"].ToString(); } //Agrego el subtitulo writer.DirectContent.BeginText(); writer.DirectContent.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 12); writer.DirectContent.SetTextMatrix((document.PageSize.Width / 2) - subTitulo.Length - 13, document.PageSize.GetTop(document.TopMargin) + 30); writer.DirectContent.ShowTextAligned(PdfContentByte.ALIGN_CENTER, subTitulo, (document.PageSize.Width / 2), document.PageSize.GetTop(document.TopMargin) + 30, 0); writer.DirectContent.EndText(); //termino de agregar el subtitulo //creo la imagen de bureau cell = new PdfPCell(new Paragraph("")); img = Image.GetInstance(urlBase + pathImg); img.ScaleAbsolute(escalaW, escalaH); cell.AddElement(img); cell.Border = 0; tblTableTitulo.AddCell(cell); //listcells.Add(cell); if (subcontrata != "0") { titulo = ""; } //creo el titulo cell = new PdfPCell(new Paragraph(new Chunk(titulo, boldFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.PaddingTop = 13; cell.Border = 0; tblTableTitulo.AddCell(cell); //listcells.Add(cell); //agrega acreditación cell = new PdfPCell(); if (subcontrata == "0") { if (data[0]["acreditacion"] != null) { foreach (JObject jObject in data[0]["acreditacion"].Children <JToken>()) { escalaAcreW = (float)jObject["escalaWidth"]; escalaAcreH = (float)jObject["escalaHeight"]; pathAcreimg = jObject["path_img"].ToString(); img = Image.GetInstance(urlBase + pathAcreimg); img.ScaleAbsolute(escalaAcreW, escalaAcreH); cell.AddElement(img); } } } cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE; cell.Border = 0; tblTableTitulo.AddCell(cell); //listcells.Add(cell); //seteo una nueva fila //row = new PdfPRow(listcells.ToArray()); //row.SetWidths(head); //tblTableTitulo.Rows.Add(row); //listcells = new List<PdfPCell>(); //cell = new PdfPCell(new Phrase("")); //cell.Border = 0; //listcells.Add(cell); //cell = new PdfPCell(new Paragraph(new Chunk(""))); //cell.HorizontalAlignment = Element.ALIGN_CENTER; //cell.Top = 100; //cell.VerticalAlignment = Element.ALIGN_MIDDLE; //cell.Border = 0; //listcells.Add(cell); //PdfPRow rows = new PdfPRow(listcells.ToArray()); //float[] vs = { 13, 500 }; //rows.SetWidths(vs); //tblTableTitulo.Rows.Add(rows); tblTableTitulo.CompleteRow(); tblTableTitulo.SetWidths(head); //tblTableTitulo.WriteSelectedRows(0, -1,document.PageSize.GetLeft(document.LeftMargin) - 30, writer.PageSize.GetTop(document.TopMargin) + 140, writer.DirectContent); tblTableTitulo.WriteSelectedRows(0, -1, 20, writer.PageSize.GetTop(document.TopMargin) + 140, writer.DirectContent); //PdfContentByte cbtest = writer.DirectContent; //PdfPTable table = new PdfPTable(1); //table.TotalWidth = 400f; //table.AddCell("Test"); //table.WriteSelectedRows(0, -1, 200, 50, cbtest); //Create PdfTable object float[] cabecera = { 220, 80 }; PdfPTable pdfTab = new PdfPTable(cabecera.Length); pdfTab.TotalWidth = document.PageSize.Width; pdfTab.WidthPercentage = 100; pdfTab.SetWidths(cabecera); pdfTab.DefaultCell.Border = Rectangle.NO_BORDER; Chunk footer = new Chunk(footer_txt.ToString(), bold); Chunk Subfooter = new Chunk(nota_pie, normal); //byte[] b = IronBarCode.QRCodeWriter.CreateQrCode("https://app.bureauveritas.com.pe/agrifood_test/", 50, IronBarCode.QRCodeWriter.QrErrorCorrectionLevel.Medium).ToPngBinaryData(); var qr = new BarcodeQRCode(url_informe, 1, 1, null); var img_qr = qr.GetImage(); img_qr.ScaleAbsolute(50, 50); //Image imgs = Image.GetInstance(b); //List<PdfPCell> listCells = new List<PdfPCell>(); cell = new PdfPCell(new Paragraph(Subfooter)); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.Border = 0; cell.PaddingTop = 5; pdfTab.AddCell(cell); cell = new PdfPCell(); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_RIGHT; cell.AddElement(img_qr); cell.Rowspan = 2; cell.Border = 0; cell.PaddingTop = 5; pdfTab.AddCell(cell); cell = new PdfPCell(new Paragraph(footer)); cell.PaddingTop = 5; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Border = 0; pdfTab.AddCell(cell); //imagen de codigo de barras cell = new PdfPCell(); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_RIGHT; cell.Border = 0; cell.PaddingTop = 5; pdfTab.AddCell(cell); pdfTab.CompleteRow(); //pdfTab.WriteSelectedRows(0, -1, document.LeftMargin, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); pdfTab.WriteSelectedRows(0, -1, 50, writer.PageSize.GetBottom(document.BottomMargin), writer.DirectContent); } }