Create Invoice PDF using itextSharp
public bool GenerateInvoice(GenerateInvoiceRequestModel GenerateInvoiceRequest, string InvoicePath, ref string pathFileName)
{
try
{
var InvoiceDetails = GetData(InvoiceRequest);//get data for PDF
if (InvoiceDetails != null)
{
Document document = new Document();
IFont BOLD = new IFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 9, iTextSharp.text.Font.BOLD);
IFont ExtraBOLD = new IFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 13, iTextSharp.text.Font.BOLD);
IFont NORMAL = new IFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8);
IFont SMALL = new IFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, iTextSharp.text.Font.NORMAL);
IFont SMALL_BOLD = new IFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, iTextSharp.text.Font.BOLD);
iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(216f, 230f);
string InvoiceFileNm1 = string.Empty;
//InvoiceFileNm1 =InvoiceDetails.Invoice.ActualInvoiceNo +"_"+ DateTime.Now.ToString("ddMMyyhhmmss");
InvoiceFileNm1 = InvoiceDetails.Invoice.ActualInvoiceNo;
string path = string.Empty;
string InvoiceFileName = InvoiceFileNm1.Replace(@"/", "");
if (string.IsNullOrEmpty(InvoicePath))
{
throw new ApplicationException("Path Not Found.");
}
else
{
path = InvoicePath;
}
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string fileName = InvoiceFileName + ".pdf";
pathFileName = InvoicePath + fileName;
using (MemoryStream ms = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("" + pathFileName + "", FileMode.Create));
var pageEventHelper = new PageEventHelper();
writer.PageEvent = pageEventHelper;
}
//======================================== document- start ==========================================//
document.Open();
//======================================== Invoice Header Table - start ==========================================//
var tableHeaderLayout = new PdfPTable(3);
float[] headersLayout = { 50, 15, 35 };
tableHeaderLayout.SetWidths(headersLayout);
tableHeaderLayout.WidthPercentage = 100;
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("Invoice", new Font(ExtraBOLD))) { Border = 0,Colspan=3, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ")) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("GSTIN:", InvoiceDetails.CompanyDetails.GSTINNO)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Name:", InvoiceDetails.CompanyDetails.ComName)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Address:", InvoiceDetails.CompanyDetails.LocationAddress)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(" ", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Serial Number of Invoice:", InvoiceDetails.Invoice.ActualInvoiceNo)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Price and Payment Terms:", "")) { Border = 0,Colspan=2, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Date of Invoice:", InvoiceDetails.Invoice.InvoiceDate)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase(InvoiceDetails.Invoice.PriceAndPaymentTerms, new Font(NORMAL))) { Border = 0,Colspan=2, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Purchase Order No:", InvoiceDetails.Invoice.PONumber)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("PO Date:", InvoiceDetails.Invoice.PODate)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("Details of Receiver(Billed to)\n", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("Details of Consignee (Shipped to)\n", new Font(BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Name:", InvoiceDetails.Invoice.BankName)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Name:", InvoiceDetails.Invoice.ShipName)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Address:", InvoiceDetails.Invoice.BillingAddress)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("Address:", InvoiceDetails.Invoice.ShippingAddres)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("State:", InvoiceDetails.Invoice.BillStateName)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("State:", InvoiceDetails.Invoice.ShipState)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("State Code:", InvoiceDetails.Invoice.BillStateCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("State Code:", InvoiceDetails.Invoice.ShipStateCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("GSTIN/Unique ID:", InvoiceDetails.Invoice.BillGSTIN)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_LEFT });
tableHeaderLayout.AddCell(new PdfPCell(LableWithValue("GSTIN/Unique ID:", InvoiceDetails.Invoice.ShipGSTIN)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
document.Add(new Paragraph("\n"));
document.Add(tableHeaderLayout);
//===== Invoice Header Table- end =====//
//===================================================== Product Details Table - start =======================================================//
PdfPTable pdfTable = new PdfPTable(15);
//pdfTable.LockedWidth = true;
float[] widths = new float[] { 4, 14, 9, 4, 4, 6, 10, 6, 10,4, 7,4,7, 4, 7 };
pdfTable.SetWidths(widths);
pdfTable.WidthPercentage = 100;
var tableInnerLayout_cgst = new PdfPTable(2);
float[] innerheaders = { 40, 60 };
tableInnerLayout_cgst.SetWidths(innerheaders);
tableInnerLayout_cgst.AddCell(new PdfPCell(new Phrase("CGST", new Font(SMALL))) { Colspan = 2, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_cgst.AddCell(new PdfPCell(new Phrase("Rate", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_cgst.AddCell(new PdfPCell(new Phrase("Amount", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
var tableInnerLayout_SGST = new PdfPTable(2);
tableInnerLayout_SGST.SetWidths(innerheaders);
tableInnerLayout_SGST.AddCell(new PdfPCell(new Phrase("SGST", new Font(SMALL))) { Colspan = 2, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_SGST.AddCell(new PdfPCell(new Phrase("Rate", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_SGST.AddCell(new PdfPCell(new Phrase("Amount", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
var tableInnerLayout_IGST = new PdfPTable(2);
tableInnerLayout_IGST.SetWidths(innerheaders);
tableInnerLayout_IGST.AddCell(new PdfPCell(new Phrase("IGST", new Font(SMALL))) { Colspan = 2, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_IGST.AddCell(new PdfPCell(new Phrase("Rate", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
tableInnerLayout_IGST.AddCell(new PdfPCell(new Phrase("Amount", new Font(SMALL))) { HorizontalAlignment = Element.ALIGN_CENTER, Padding = 3, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell cell;
cell = new PdfPCell(new Phrase("Sr.No", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Description of Goods", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("HSN", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Qty", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Unit", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Rate per Unit", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Total", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Discount", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Taxable Value", SMALL));
pdfTable.AddCell(cell);
pdfTable.AddCell(new PdfPCell(tableInnerLayout_cgst) {Colspan=2,Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 0, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
pdfTable.AddCell(new PdfPCell(tableInnerLayout_SGST) { Colspan = 2,Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 0, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
pdfTable.AddCell(new PdfPCell(tableInnerLayout_IGST) { Colspan = 2,Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 0, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
// loop here for multiple Products-Start
//===================================
//foreach (var item in paymentDueList.Invoice)
//{
int a = 1;
cell = new PdfPCell(new Phrase(a.ToString(), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(InvoiceDetails.Invoice.GoodsDescription, SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(InvoiceDetails.Invoice.HSN, SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(InvoiceDetails.Invoice.Quantity, SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(InvoiceDetails.Invoice.Quantity, SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.UnitPrice), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Total), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Discount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Total), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.CGSTRate), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.CGSTAmount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.SGSTRate), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.SGSTAmount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.IGSTRate), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.IGSTAmount), SMALL));
pdfTable.AddCell(cell);
a++;
// }
// loop end
//=========
//============================blank line loop -start=======================//
for (int i = 1; i <= 3; i++)
{
for (int j = 1; j <= 15; j++)
{
cell = new PdfPCell(new Phrase(" ", SMALL));
pdfTable.AddCell(cell);
}
}
cell = new PdfPCell(new Phrase("Freight", NORMAL));
cell.Colspan = 6;
cell.Border = 0;
cell.BorderWidthLeft = 0.5f;
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n}", InvoiceDetails.Invoice.FreightTotal), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Insurance", NORMAL));
cell.Colspan = 6;
cell.Border = 0;
cell.BorderWidthLeft = 0.5f;
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n}",""), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Packing and forwarding charges", NORMAL));
cell.Colspan = 6;
cell.Border = 0;
cell.BorderWidthLeft = 0.5f;
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n}",""), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("Total", SMALL_BOLD));
cell.Colspan = 6;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
cell.Border = 0;
cell.BorderWidthLeft = 0.5f;
cell.BorderWidthBottom = 0.5f;
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Total), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Discount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.Total), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.CGSTAmount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.SGSTAmount), SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase("", SMALL));
pdfTable.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("{0:n0}", InvoiceDetails.Invoice.IGSTAmount), SMALL));
pdfTable.AddCell(cell);
document.Add(pdfTable);
//====== Product Details Table- end ============//
//============================================================== Invoice Table Footer Section - start ==============================================================//
var tblFooter = new PdfPTable(3);
float[] tblFooterLayout = { 45,30,25};
tblFooter.SetWidths(tblFooterLayout);
tblFooter.WidthPercentage = 100;
tblFooter.AddCell(new PdfPCell(LableWithValue("Total Invoice Value (in figure):", String.Format("{0:n0}", InvoiceDetails.Invoice.TotalSalesPrice))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(LableWithValue("Total Invoice Value (in words):", InvoiceDetails.Invoice.AmountWords)) { Border = 0,Colspan=3, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Amount of tax subject to reverse charges:" + "", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Declaration:", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Signature:", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Name of the ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Signatory:", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Designation / Status:", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase(" ", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(LableWithValue("Electronic Reference Number:", InvoiceDetails.Invoice.ActualInvoiceNo)) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
tblFooter.AddCell(new PdfPCell(new Phrase("Date:"+"", new Font(NORMAL))) { Border = 0, HorizontalAlignment = Element.ALIGN_LEFT });
//---------------------------------
document.Add(tblFooter);
//============== Invoice Table Footer Section - end =================//
document.Close();
//======== document- end =====//
}
}
catch (Exception ex)
{
ApiErrorLogger.WriteAppError(this.GetType().ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
return false;
}
return true;
}
/// <summary>
/// Description :- Add Lable and Value and return complete Phrase in response
/// Created by : -Nitin kumar
/// </summary>
/// <param name="Title"></param>
/// <param name="Description"></param>
/// <returns></returns>
public static Phrase LableWithValue(string Title,string Description)
{
var normalFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8);
var boldFont = FontFactory.GetFont(FontFactory.TIMES_BOLD, 8);
var titleChunk = new Chunk(Title+" ", boldFont);
var descriptionChunk = new Chunk(Description, normalFont);
var phrase = new Phrase(titleChunk);
phrase.Add(descriptionChunk);
return phrase;
}