public static string PrintRawMaterial(IEnumerable <GrindingMaterial> materials, string folderPath, int ID, string CreatedBy, int EmployeeID) { var employee = EmployeeLogic.GetEmployeeByID(EmployeeID).FirstOrDefault(); var batchDetail = GrindingLogic.GetGrindingBatches(ID).FirstOrDefault(); bool exists = Directory.Exists(folderPath); if (!exists) { Directory.CreateDirectory(folderPath); } DirectoryInfo info = new DirectoryInfo(folderPath); FileInfo[] files = info.GetFiles().Where(p => p.CreationTime <= DateTime.Now.AddDays(-1)).ToArray(); foreach (var file in files) { file.Delete(); } var document = new iTextSharp.text.Document(PageSize.A4, 30f, 30f, 0f, 50f); var pdffilename = "GrindingMaterial" + DateTime.Now.ToString("h:mm:ss").Replace(":", ""); var writer = PdfWriter.GetInstance(document, new FileStream(folderPath + "/" + pdffilename + ".PDF", FileMode.Create)); writer.PageEvent = new PDFFooter(CreatedBy); document.Open(); var widths = new float[] { 15f, 30f, 10f, 60f }; var table = new PdfPTable(4); table.HeaderRows = 6; table.HorizontalAlignment = 0; table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; table.LockedWidth = true; table.SetWidths(widths); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; var cell = new PdfPCell(new Phrase("MEHUL ELECTRO INSULATING INDUSTRIES", CommonFunction.fontTitle17)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("2610/A, Ph-4, G.I.D.C., Vatva, Ahmedabad 382 445", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Phone : 2584 2331/2, Fax: 2584 0356", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Email : [email protected], [email protected]", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Raw Materials Required For Grinding", CommonFunction.fontTitle13)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.MARKED; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); if (batchDetail != null) { cell = new PdfPCell(new Phrase("Batch No :" + batchDetail.BatchNo, CommonFunction.fontTitle13)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 4; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; table.AddCell(cell); var headertable = new PdfPTable(2); var headerwidths = new float[] { 55f, 45f }; headertable.HorizontalAlignment = 0; headertable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; headertable.LockedWidth = true; headertable.SetWidths(headerwidths); headertable.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; cell = new PdfPCell(new Phrase("Product Name :" + batchDetail.ProductName, CommonFunction.font10)); headertable.AddCell(cell); cell = new PdfPCell(new Phrase("Product Code :" + ProductLogic.GetProductByID(batchDetail.ProductID).FirstOrDefault().PrintName, CommonFunction.font10)); headertable.AddCell(cell); cell = new PdfPCell(new Phrase("Shade :" + batchDetail.ShadeName, CommonFunction.font10)); cell.Colspan = 2; headertable.AddCell(cell); cell = new PdfPCell(new Phrase("Customer Name :", CommonFunction.font10)); cell.Colspan = 2; headertable.AddCell(cell); cell = new PdfPCell(new Phrase("Batch Starting Date :" + DateTime.Now.ToString("dd/MM/yyyy"), CommonFunction.font10)); headertable.AddCell(cell); var batchstarttimetable = new PdfPTable(2); var batchwidths = new float[] { 50f, 50f }; batchstarttimetable.HorizontalAlignment = 0; batchstarttimetable.SetWidths(batchwidths); batchstarttimetable.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; cell = new PdfPCell(new Phrase("Time :" + DateTime.Now.ToString("hh:mm:ss tt"), CommonFunction.font10)); batchstarttimetable.AddCell(cell); cell = new PdfPCell(new Phrase("Batch Qty :" + batchDetail.ProductionQty + " Kg", CommonFunction.font10)); batchstarttimetable.AddCell(cell); cell = new PdfPCell(batchstarttimetable); headertable.AddCell(cell); cell = new PdfPCell(new Phrase("Batch Completion Date :", CommonFunction.font10)); headertable.AddCell(cell); var batchcompletiontimetable = new PdfPTable(2); batchcompletiontimetable.HorizontalAlignment = 0; batchcompletiontimetable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; batchcompletiontimetable.LockedWidth = true; batchcompletiontimetable.SetWidths(headerwidths); batchcompletiontimetable.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; cell = new PdfPCell(new Phrase("Time :", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; batchcompletiontimetable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; batchcompletiontimetable.AddCell(cell); cell = new PdfPCell(batchcompletiontimetable); headertable.AddCell(cell); cell = new PdfPCell(headertable); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; table.AddCell(cell); } cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Colspan = table.NumberOfColumns; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Process", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER; table.AddCell(cell); cell = new PdfPCell(new Phrase("Product", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOX; table.AddCell(cell); cell = new PdfPCell(new Phrase("Qty", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER; cell.HorizontalAlignment = Rectangle.BOX; table.AddCell(cell); cell = new PdfPCell(new Phrase("Remarks", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.RIGHT_BORDER; cell.HorizontalAlignment = Rectangle.BOX; table.AddCell(cell); materials = materials.OrderBy(x => x.ProcessName); var prevProcess = ""; foreach (var material in materials) { var innercell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); if (string.IsNullOrEmpty(prevProcess) || !prevProcess.Equals(material.ProcessName)) { innercell = new PdfPCell(new Phrase(material.ProcessName, CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER; innercell.PaddingBottom = 4; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(material.ProductCode, CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(material.Qty.ToString(CommonFunction.QtyFormat), CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; innercell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_RIGHT; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(" ", CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; table.AddCell(innercell); } else { innercell = new PdfPCell(new Phrase(" ", CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.LEFT_BORDER; innercell.PaddingBottom = 4; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(material.ProductCode, CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(material.Qty.ToString(CommonFunction.QtyFormat), CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; innercell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_RIGHT; table.AddCell(innercell); innercell = new PdfPCell(new Phrase(" ", CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; table.AddCell(innercell); } prevProcess = material.ProcessName; } cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Border = iTextSharp.text.Rectangle.TOP_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); var batchDetails = BatchLogic.GetBatchDetails(ID); var packingTable = new PdfPTable(2); packingTable.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_LEFT; packingTable.TotalWidth = (document.PageSize.Width - document.LeftMargin - document.RightMargin) / 2; packingTable.LockedWidth = true; packingTable.DefaultCell.Border = Rectangle.BOX; if (batchDetails != null) { var innercell = new PdfPCell(new Phrase("Packing Details", CommonFunction.fontTitle13)); innercell.Border = iTextSharp.text.Rectangle.BOX; innercell.Colspan = 2; packingTable.AddCell(innercell); innercell = new PdfPCell(new Phrase("Name", CommonFunction.font10)); innercell.Border = iTextSharp.text.Rectangle.BOX; packingTable.AddCell(innercell); innercell = new PdfPCell(new Phrase("Qty", CommonFunction.font10)); innercell.Border = iTextSharp.text.Rectangle.BOX; packingTable.AddCell(innercell); foreach (var detail in batchDetails) { innercell = new PdfPCell(new Phrase(detail.PackingName, CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; packingTable.AddCell(innercell); innercell = new PdfPCell(new Phrase(detail.Qty, CommonFunction.font10Normal)); innercell.Border = iTextSharp.text.Rectangle.BOX; packingTable.AddCell(innercell); } } document.Add(table); document.Add(packingTable); var othersTable = new PdfPTable(2); othersTable.DefaultCell.Border = Rectangle.BOX; othersTable.TotalWidth = (document.PageSize.Width - document.LeftMargin - document.RightMargin) / 2; othersTable.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_LEFT; othersTable.LockedWidth = true; cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Colspan = table.NumberOfColumns; cell.Border = Rectangle.NO_BORDER; othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Border = Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; othersTable.AddCell(cell); cell = new PdfPCell(new Phrase("Grinding Information", CommonFunction.fontTitle13)); cell.Colspan = 2; othersTable.AddCell(cell); cell = new PdfPCell(new Phrase("Hegmanguage : ", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(batchDetail.HasHymenGuage ? "Yes" : "No", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase("Reading 1", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase("Reading 2", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase("Pigment Dispersion : ", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(batchDetail.HasPigmentDispersion ? "Yes" : "No", CommonFunction.font10Normal)); othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; othersTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font8)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; othersTable.AddCell(cell); document.Add(othersTable); var shadeMachingTable = new PdfPTable(2); shadeMachingTable.DefaultCell.Border = Rectangle.BOX; shadeMachingTable.TotalWidth = (document.PageSize.Width - document.LeftMargin - document.RightMargin) / 2; shadeMachingTable.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_LEFT; shadeMachingTable.LockedWidth = true; cell = new PdfPCell(new Phrase("Shade Matching Type", CommonFunction.fontTitle13)); cell.Colspan = 2; shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase("Type : ", CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase((batchDetail.ShadeMaching == "1" ? "Master Panel" : "Last Supply"), CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase("Panel Number : ", CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase(batchDetail.PanelNumber, CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase("Rack Number : ", CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); cell = new PdfPCell(new Phrase(batchDetail.RackNumber, CommonFunction.font10Normal)); shadeMachingTable.AddCell(cell); document.Add(shadeMachingTable); document.Close(); return(pdffilename + ".PDF"); }
public static string Print(int ID, string folderPath, string CreatedBy) { var dispatch = GetDispatchByID(ID).FirstOrDefault(); var order = OrderLogic.GetOrderByID(dispatch.OrderID).FirstOrDefault(); var address = PartyAddressLogic.GetAddressById(dispatch.DeliveryAddressID); var dispatchDetail = GetDispatchDetailByDispatchID(ID); bool exists = Directory.Exists(folderPath); if (!exists) { Directory.CreateDirectory(folderPath); } DirectoryInfo info = new DirectoryInfo(folderPath); FileInfo[] files = info.GetFiles().Where(p => p.CreationTime <= DateTime.Now.AddDays(-1)).ToArray(); foreach (var file in files) { file.Delete(); } var document = new iTextSharp.text.Document(PageSize.A4, 30f, 30f, 0f, 250f); var pdffilename = "Dispatch" + DateTime.Now.ToString("h:mm:ss").Replace(":", ""); var writer = PdfWriter.GetInstance(document, new FileStream(folderPath + "/" + pdffilename + ".PDF", FileMode.Create)); document.Open(); var widths = new float[] { 15f, 30f, 10f, 60f }; var table = new PdfPTable(4); table.HeaderRows = 6; table.HorizontalAlignment = 0; table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; table.LockedWidth = true; table.SetWidths(widths); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; var cell = new PdfPCell(new Phrase("MEHUL ELECTRO INSULATING INDUSTRIES", CommonFunction.fontTitle17)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("2610/A, Ph-4, G.I.D.C., Vatva, Ahmedabad 382 445", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Phone : 2584 2331/2, Fax: 2584 0356", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase("Email : [email protected], [email protected]", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER; cell.Border = iTextSharp.text.Rectangle.MARKED; cell.Colspan = table.NumberOfColumns; table.AddCell(cell); if (dispatch != null) { cell = new PdfPCell(new Phrase(dispatch.PartyName, CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 2; table.AddCell(cell); cell = new PdfPCell(new Phrase("Challan No :" + dispatch.DONo, CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 2; table.AddCell(cell); cell = new PdfPCell(new Phrase(address.Address1 + "," + address.Address2 + "," + address.Address3 + "," + address.City + "," + address.State, CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; cell.Colspan = 2; table.AddCell(cell); cell = new PdfPCell(new Phrase("Challan Date :" + dispatch.DODate.ToString("dd/MM/yyyy"), CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; cell.Colspan = 2; table.AddCell(cell); var detailTable = new PdfPTable(8); detailTable.HorizontalAlignment = 0; detailTable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; detailTable.LockedWidth = true; var detailWidths = new[] { 5f, 35f, 16f, 10f, 8f, 8f, 10f, 8f }; detailTable.SetWidths(detailWidths); detailTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell = new PdfPCell(new Phrase("Sr.", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Product", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Shade", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Packing", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Qty", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Ltr", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); //cell = new PdfPCell(new Phrase("Drum/Box", CommonFunction.font10)); //cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; //cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; //detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Rate", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Per", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER; detailTable.AddCell(cell); decimal i = 1, totalQty = 0, totalLtr = 0, totalRate = 0; foreach (var detail in dispatchDetail) { var product = ProductLogic.GetProductByID(detail.ProductID).FirstOrDefault(); var packing = PackingLogic.GetPackingByID(detail.PackingID).FirstOrDefault(); cell = new PdfPCell(new Phrase(i.ToString(), CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(detail.ProductName + " (" + product.PrintName + ")", CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(detail.ShadeName, CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(detail.PackingName, CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(detail.Qty, CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(Convert.ToString(Convert.ToDecimal(detail.Qty) * Convert.ToDecimal(packing.ConversionFactorWithLtr)), CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); //decimal drumCount = 0; //cell = new PdfPCell(new Phrase(drumCount.ToString(), CommonFunction.font10Normal)); //cell.Border = iTextSharp.text.Rectangle.NO_BORDER; //cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; //detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(detail.Rate, CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(product.ProuctUnitName, CommonFunction.font10Normal)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; detailTable.AddCell(cell); i++; totalQty += Convert.ToDecimal(detail.Qty); totalLtr += Convert.ToDecimal(detail.Qty) * Convert.ToDecimal(packing.ConversionFactorWithLtr); //totalDrum += drumCount; totalRate += Convert.ToDecimal(detail.Rate); } writer.PageEvent = new DispatchFooter(dispatch.DONo, dispatch.DODate, totalQty.ToString(), totalLtr.ToString(), dispatch.PartyName, address.Address1); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 8; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 8; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("Totals : ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; cell.Colspan = 4; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(totalQty.ToString(), CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(totalLtr.ToString(), CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); //cell = new PdfPCell(new Phrase(totalDrum.ToString(), CommonFunction.font10)); //cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; //cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; //detailTable.AddCell(cell); cell = new PdfPCell(new Phrase(totalRate.ToString(), CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(new Phrase("", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.TOP_BORDER; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; detailTable.AddCell(cell); cell = new PdfPCell(detailTable); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 4; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 4; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Phrase(" ", CommonFunction.font10)); cell.Border = iTextSharp.text.Rectangle.NO_BORDER; cell.Colspan = 4; cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; table.AddCell(cell); document.Add(table); } document.Close(); return(pdffilename + ".PDF"); }