public void GenerateQAIssues(DataSet ds, QuantityAccountEntity quantityAccount) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = quantityAccount.GCode + GlobalVariable.QuantityAccountIssues; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + quantityAccount.UserId; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); // isDuplicate = ReceiptId == "0" ? false : true; streamWriter = new StreamWriter(filePath, true); AddDocHeaderForReceipt(streamWriter, quantityAccount); AddDetails(streamWriter, ds); //AddFooter(streamWriter, chequeEntity); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public Tuple <bool, string> GenerateGSTFile(CommonEntity entity) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = entity.GCode + GlobalVariable.GSTFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); CreateGSTTextFile(streamWriter, entity); streamWriter.Flush(); return(new Tuple <bool, string>(true, "GST File is Generated Sccessfully!")); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); return(new Tuple <bool, string>(false, "GST File is not Generated!")); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
public void GenerateIssueMemoReceipt(CommonEntity commonEntity, string GlobalFileName, string reportName, int reportType) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = commonEntity.GCode + GlobalFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + commonEntity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); // isDuplicate = ReceiptId == "0" ? false : true; streamWriter = new StreamWriter(filePath, true); AddDocHeaderForReceipt(streamWriter, commonEntity, reportName); AddDetails(streamWriter, commonEntity.dataSet, reportType); //AddFooter(streamWriter, chequeEntity); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateWriteOffReport(CommonEntity entity) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = entity.GCode + GlobalVariable.WriteOFFReportFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); CommodityWiseIssueMemoReport(streamWriter, entity); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
public void GenerateDeliveryOrderText(DocumentDeliveryOrderEntity deliveryOrderList) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = deliveryOrderList.IssuerCode + GlobalVariable.DocumentDOFileName; fPath = GlobalVariable.ReportPath + "Reports"; manageReport.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + deliveryOrderList.UserID; //ManageReport.GetDateForFolder(); manageReport.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; manageReport.DeleteFileIfExists(filePath); // isDuplicate = ReceiptId == "0" ? false : true; streamWriter = new StreamWriter(filePath, true); AddDocHeaderForDeliveryOrder(streamWriter, deliveryOrderList); AddPaymentDetails(streamWriter, deliveryOrderList); AddItemsDetails(streamWriter, deliveryOrderList); AddMarginDetails(streamWriter, deliveryOrderList); AddFooter(streamWriter, deliveryOrderList); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
public void GenerateReceipt(DocumentStockReceiptList stockReceipt) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; bool isDuplicate = false; try { fileName = stockReceipt.ReceivingCode + GlobalVariable.DocumentReceiptFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + stockReceipt.UserID; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); // isDuplicate = ReceiptId == "0" ? false : true; isDuplicate = stockReceipt.UnLoadingSlip == null ? false : stockReceipt.UnLoadingSlip.ToUpper() == "Y" ? true : false; streamWriter = new StreamWriter(filePath, true); AddDocHeaderForReceipt(streamWriter, stockReceipt, isDuplicate); AddDetails(streamWriter, stockReceipt); AddFooter(streamWriter, stockReceipt); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// Generate the transaction receipt /// </summary> /// <param name="entity">Common entity</param> public void GenerateTransactionReceipt(CommonEntity entity) { string fPath = string.Empty, sPath = string.Empty, sFileName = string.Empty; string filePath = string.Empty; StreamWriter sw = null; try { GName = entity.dataSet.Tables[0].Rows[0]["Godownname"].ToString(); RegionName = entity.dataSet.Tables[0].Rows[0]["Region"].ToString(); sFileName = entity.GCode + GlobalVariable.TransactionReceiptFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists sPath = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(sPath); //delete file if exists filePath = sPath + "//" + sFileName + ".txt"; report.DeleteFileIfExists(filePath); sw = new StreamWriter(filePath, true); WriteTransactionForAbstract(sw, entity); sw.Flush(); sw.Close(); //send mail to corresponding godown. } catch (Exception ex) { AuditLog.WriteError(ex.Message + " : " + ex.StackTrace); } }
/// <summary> /// /// </summary> /// <param name="stockIssuesEntity"></param> public void GenerateStackCardRegister(List <StackCardRegisterEntity> stackCardRegisters, StackEntity stackEntity) { // AuditLog.WriteError("GeneratestockIssuesEntityRegister"); string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = stackEntity.GCode + GlobalVariable.StackCardRegister; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + stackEntity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); AddDocHeaderForIssues(streamWriter, stackEntity); AddDetails(streamWriter, stackCardRegisters, stackEntity); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateStockStatementReport(List <DailyStockDetailsEntity> stockDetailsEntity, StockParameter param) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = (param.GCode + GlobalVariable.StockStatementFileName); fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + param.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); StockStatementReport(streamWriter, stockDetailsEntity, param); //List<DailyStockDetailsEntity> dailyStocks = new List<DailyStockDetailsEntity>(); //dailyStocks = report.ConvertDataTableToList<DailyStockDetailsEntity>(dailyStocks); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateDemandDraftReport(CommonEntity entity) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { fileName = entity.GCode + GlobalVariable.DODemandDraftBankFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); DataTable dt = new DataTable(); dt = entity.dataSet.Tables[0]; DateWiseCommodityIssueMemoReport(streamWriter, entity, dt); streamWriter.Flush(); // Generate date for streamWriter = null; fileName = entity.GCode + GlobalVariable.DODemandDraftDateFileName; filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); DataTable ndt1 = new DataTable(); DataView dv = entity.dataSet.Tables[0].DefaultView; dv.Sort = "Dodate asc"; ndt1 = dv.ToTable(); DateWiseCommodityIssueMemoReport(streamWriter, entity, ndt1); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
public void GenerateDeliveryOrderForRegister(CommonEntity entity) { string fPath = string.Empty, sPath = string.Empty, sFileName = string.Empty; string filePath = string.Empty; StreamWriter sw = null; try { GName = entity.dataTable.Rows[0]["Godown"].ToString(); Regioncode = entity.dataTable.Rows[0]["Region"].ToString(); sFileName = entity.GCode + GlobalVariable.StockDORegisterFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists sPath = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(sPath); //delete file if exists filePath = sPath + "//" + sFileName + ".txt"; report.DeleteFileIfExists(filePath); sw = new StreamWriter(filePath, true); WriteDORegForDateWise(sw, entity); // sw.WriteLine((char)12); List <DORegEntity> dORegEntities = new List <DORegEntity>(); dORegEntities = report.ConvertDataTableToList <DORegEntity>(entity.dataTable); WriteDORegforSocityandScheme(sw, dORegEntities, entity); WriteDORegforItemandScheme(sw, dORegEntities, entity); WriteDORegforItem(sw, dORegEntities, entity); sw.Flush(); //send mail to corresponding godown. } catch (Exception ex) { AuditLog.WriteError("GenerateDeliveryOrderForRegister " + ex.Message + " : " + ex.StackTrace); } finally { sw.Close(); sw = null; fPath = string.Empty; sFileName = string.Empty; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateStockReceiptRegister(CommonEntity entity) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { GName = entity.dataSet.Tables[0].Rows[0]["Godownname"].ToString(); RName = entity.dataSet.Tables[0].Rows[0]["Region"].ToString(); fileName = entity.GCode + GlobalVariable.StockReceiptRegisterFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); DateWiseStockReceiptRegister(streamWriter, entity); List <StockReceiptList> stockReceiptList = new List <StockReceiptList>(); stockReceiptList = report.ConvertDataTableToList <StockReceiptList>(entity.dataSet.Tables[0]); // DateWiseStockReceiptRegister(streamWriter, entity); StockReceiptAbstractRecdTypeAndSchemeWise(streamWriter, stockReceiptList, entity); StockReceiptAbstractSchemeAndCommodityWise(streamWriter, stockReceiptList, entity); StockReceiptAbstractStackNoAndCommodity(streamWriter, stockReceiptList, entity); StockReceiptAbstractCommodityWise(streamWriter, stockReceiptList, entity); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateHullingReport(CommonEntity entity) { //AuditLog.WriteError("GenerateHullingReport"); string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { GName = entity.dataSet.Tables[0].Rows[0]["Godownname"].ToString(); RName = entity.dataSet.Tables[0].Rows[0]["Region"].ToString(); fileName = entity.GCode + GlobalVariable.HullingDetailsReportFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); DateWiseHullingDetails(streamWriter, entity); List <HullingReportEntity> hullingReportList = new List <HullingReportEntity>(); hullingReportList = report.ConvertDataTableToList <HullingReportEntity>(entity.dataSet.Tables[0]); HullingDetailsAbstract(streamWriter, hullingReportList, entity); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateSalesIssueMemoAbstract(CommonEntity entity) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { GName = entity.GName; RName = entity.RName; fileName = entity.GCode + GlobalVariable.SalesIssueMemoAbstractFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); WriteSalesIssueMemoAbstract(streamWriter, entity); //List<CommodityIssueMemoEntity> commodityIssueList = new List<CommodityIssueMemoEntity>(); //commodityIssueList = report.ConvertDataTableToList<CommodityIssueMemoEntity>(entity.dataSet.Tables[0]); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void GenerateGUGRReport(CommonEntity entity, GUGRParameter param) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; try { HeaderTitle = (param.Type == "GR") ? " Gunny Release Details of " : " Gunny Utilisation Details of "; fileName = (param.Type == "GR") ? (entity.GCode + GlobalVariable.GRReportFileName) : (entity.GCode + GlobalVariable.GUReportFileName); fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + entity.UserName; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); streamWriter = new StreamWriter(filePath, true); DateWiseCommodityWiseGUGRReport(streamWriter, entity); List <GUList> guList = new List <GUList>(); guList = report.ConvertDataTableToList <GUList>(entity.dataSet.Tables[0]); WriteGUGRAbstract(streamWriter, guList, entity); streamWriter.Flush(); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
public Tuple <bool, string> GeneratePDF(DocumentStockReceiptList stockReceipt = null) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; try { fileName = stockReceipt.ReceivingCode + GlobalVariable.ReceiptAckFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + stockReceipt.UserID; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".pdf"; report.DeleteFileIfExists(filePath); iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4, 5f, 5f, 5f, 5f); //Create PDF Table FileStream fs = new FileStream(filePath, FileMode.Create); //Create a PDF file in specific path PdfWriter writer = PdfWriter.GetInstance(document, fs); // Add meta information to the document document.AddAuthor("Dulasiayya from BonTon"); document.AddCreator("Acknolowdgement for particuar document"); document.AddKeywords("TNCSC- Webcopy "); document.AddSubject("Document subject - Ack Web Copy "); document.AddTitle("The document title - PDF creation for Receipt Document"); //Open the PDF document document.Open(); string imagePath = GlobalVariable.ReportPath + "layout\\images\\dashboard\\tncsc-logo.PNG"; iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imagePath); img.Alignment = Element.ALIGN_CENTER; img.ScaleToFit(80f, 60f); imagePath = GlobalVariable.ReportPath + "layout\\images\\dashboard\\watermark.PNG"; iTextSharp.text.Image imgWaterMark = iTextSharp.text.Image.GetInstance(imagePath); imgWaterMark.ScaleToFit(300, 450); imgWaterMark.Alignment = iTextSharp.text.Image.UNDERLYING; imgWaterMark.SetAbsolutePosition(120, 450); document.Add(imgWaterMark); //|----------------------------------------------------------------------------------------------------------| //Create the table PdfPTable table = new PdfPTable(2); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; //table.setBorder(Border.NO_BORDER); //set overall width table.WidthPercentage = 100f; //set column widths int[] firstTablecellwidth = { 20, 80 }; table.SetWidths(firstTablecellwidth); //iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", "16", iTextSharp.text.Font.NORMAL); PdfPCell cell = new PdfPCell(img); cell.Rowspan = 3; cell.BorderWidth = 0; // cell.Border = (Border.NO_BORDER); table.AddCell(cell); PdfPCell cell1 = new PdfPCell(new Phrase("TAMILNADU CIVIL SUPPLIES CORPORATION")); cell1.HorizontalAlignment = Element.ALIGN_CENTER; cell1.BorderWidth = 0; table.AddCell(cell1); cell1 = new PdfPCell(new Phrase("Region Name : " + stockReceipt.RegionName)); cell1.HorizontalAlignment = Element.ALIGN_CENTER; cell1.BorderWidth = 0; table.AddCell(cell1); cell1 = new PdfPCell(new Phrase("")); cell1.BorderWidth = 0; table.AddCell(cell1); document.Add(table); Paragraph heading = new Paragraph(" STOCK RECEIPT ACKNOWLEDGMENT WEB COPY"); heading.Alignment = Element.ALIGN_CENTER; document.Add(heading); AddSpace(document); AddHRLine(document); //add header values AddheaderValues(document, stockReceipt); AddSpace(document); AddDetails(document, stockReceipt); AddSpace(document); AddLorryInfo(document, stockReceipt); AddSpace(document); AddFSSAI(document); AddSign(document, stockReceipt.ReceivingCode); AddSpace(document); AddRemarks(document, stockReceipt); AddSpace(document); AddHRLine(document); AddFooter(document, stockReceipt); //Add border to page PdfContentByte content = writer.DirectContent; Rectangle rectangle = new Rectangle(document.PageSize); rectangle.Left += document.LeftMargin; rectangle.Right -= document.RightMargin; rectangle.Top -= document.TopMargin; rectangle.Bottom += document.BottomMargin; content.SetColorStroke(BaseColor.Black); content.Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height); content.Stroke(); // Close the document document.Close(); // Close the writer instance writer.Close(); // Always close open filehandles explicity fs.Close(); } catch (Exception ex) { AuditLog.WriteError(" GeneratePDF : " + ex.Message + " " + ex.StackTrace); return(new Tuple <bool, string>(false, "Please Contact system Admin")); } return(new Tuple <bool, string>(true, "Print Generated Successfully")); }