I check this link,But Its not Working.
pdf files created with the code of itextsharp pdf format.
i m showing that file with in the browser With Same Tab.
I want to open/show pdf file in the new tab of browser window.
How can i solve the problem ?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PDFOpenInNewTabOfBrowser.aspx.cs" Inherits="PDFOpenInNewTabOfBrowser" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_Click" />
</div>
</form>
</body>
</html>
using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class PDFOpenInNewTabOfBrowser : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InventoryDB"].ConnectionString);
string BillNumber = string.Empty;
string BillDate = string.Empty;
string PartyName = string.Empty;
int SrNo = 0;
string ProductName = string.Empty;
string ProductRate = string.Empty;
string ProductQuantity = string.Empty;
string ProductNumberOfBox = string.Empty;
string ProductAmount = string.Empty;
string AmountInWords = string.Empty;
string DiscountRate = string.Empty;
string DiscountAmount = string.Empty;
string WithDicoount_TotalAmount = string.Empty;
string VatRate = string.Empty;
string VatAmount = string.Empty;
string ItemTotalAmount = string.Empty;
string WithVat_GrandTotal = string.Empty;
string TotalQuantity = string.Empty;
string TotalBoxes = string.Empty;
string BuyersVatTinNo = string.Empty;
string BuyersCstTinNo = string.Empty;
string SellerVatTinNo = string.Empty;
string SellerCstTinNo = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
}
public void PrintBill()
{
var FontTextColor = FontFactory.GetFont("Arial", 10, iTextSharp.text.BaseColor.WHITE);
var MainTextRegular = FontFactory.GetFont("Arial", 8, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularSmall = FontFactory.GetFont("Arial", 7, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularExtraSmall = FontFactory.GetFont("Arial", 6, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularBold = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
var MainTextRegularSmallBold = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.BOLD);
var MainTextRegularHead = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
var MainTextBold = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD);
var MainHeaderTextBold = FontFactory.GetFont("Arial", 15, iTextSharp.text.Font.BOLD);
var MainHeaderText = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
iTextSharp.text.Font Fonth1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10f);
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A4.Rotate(), 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
//created Master table
PdfPTable MasterMainTable = new PdfPTable(new float[] { 48f, 4f, 48f });
MasterMainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MasterMainTable.TotalWidth = 800f;
MasterMainTable.LockedWidth = true;
MasterMainTable.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell MasterMainTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell01.HorizontalAlignment = 0;
MasterMainTable_Cell01.BorderWidth = 0;
PdfPCell MasterMainTable_SpaceCell = new PdfPCell(new iTextSharp.text.Paragraph(" "));
MasterMainTable_SpaceCell.HorizontalAlignment = 0;
MasterMainTable_SpaceCell.BorderWidth = 0;
PdfPCell MasterMainTable_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell02.HorizontalAlignment = 0;
MasterMainTable_Cell02.BorderWidth = 0;
//print data from here
PdfPTable MainTable = new PdfPTable(1);
MainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MainTable.TotalWidth = 400f;
MainTable.LockedWidth = true;
MainTable.HorizontalAlignment = Element.ALIGN_LEFT;
//1st row
PdfPCell MainTableCell1 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MainTableCell1.HorizontalAlignment = 0;
MainTableCell1.BorderWidth = 1;
//created nested table
PdfPTable nestedTable = new PdfPTable(new float[] { 8f, 32f, 15f, 15f, 15f, 15f });
nestedTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTable.TotalWidth = 400f;
nestedTable.LockedWidth = true;
PdfPCell nestedTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainHeaderTextBold));
nestedTable_Cell01.HorizontalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.BorderWidth = 0;
nestedTable_Cell01.Colspan = 1;
nestedTable_Cell01.Rowspan = 6;
PdfPCell nestedTableCell01 = new PdfPCell(new iTextSharp.text.Paragraph("", MainHeaderTextBold));
nestedTableCell01.HorizontalAlignment = 1;
nestedTableCell01.BorderWidth = 0;
nestedTableCell01.Colspan = 5;
PdfPCell nestedTableCell02 = new PdfPCell(new iTextSharp.text.Paragraph(", ", MainTextRegular));
nestedTableCell02.HorizontalAlignment = 1;
nestedTableCell02.BorderWidth = 0;
nestedTableCell02.Colspan = 5;
PdfPCell nestedTableCell03 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell03.HorizontalAlignment = 1;
nestedTableCell03.BorderWidth = 0;
nestedTableCell03.Colspan = 5;
PdfPCell nestedTableCell04 = new PdfPCell(new iTextSharp.text.Paragraph("\n\n", MainTextRegular));
nestedTableCell04.HorizontalAlignment = 1;
nestedTableCell04.BorderWidth = 0;
nestedTableCell04.Colspan = 5;
PdfPCell nestedTableCell05 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell05.HorizontalAlignment = 1;
nestedTableCell05.BorderWidth = 0;
nestedTableCell05.Colspan = 5;
PdfPCell nestedTableCell06 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell06.HorizontalAlignment = 1;
nestedTableCell06.BorderWidth = 0;
nestedTableCell06.Colspan = 5;
nestedTable.AddCell(nestedTable_Cell01);
nestedTable.AddCell(nestedTableCell01);
nestedTable.AddCell(nestedTableCell02);
nestedTable.AddCell(nestedTableCell03);
nestedTable.AddCell(nestedTableCell04);
nestedTable.AddCell(nestedTableCell05);
nestedTable.AddCell(nestedTableCell06);
PdfPCell MainTableCell11 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
MainTableCell11.HorizontalAlignment = 1;
MainTableCell11.BorderWidth = 1;
MainTableCell11.Colspan = 6;
PdfPTable nestedTableForCell11 = new PdfPTable(new float[] { 20f, 60f, 20f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 400f;
nestedTableForCell11.LockedWidth = true;
PdfPCell nestedTableForCell11_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Bill No :" + BillNumber + "", MainTextRegular));
nestedTableForCell11_Cell01.HorizontalAlignment = 0;
nestedTableForCell11_Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("TAX INVOICE", MainTextRegularBold));
nestedTableForCell11_Cell02.HorizontalAlignment = 1;
nestedTableForCell11_Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("Date :" + BillDate + "", MainTextRegular));
nestedTableForCell11_Cell03.HorizontalAlignment = 2;
nestedTableForCell11_Cell03.BorderWidth = 0;
nestedTableForCell11.AddCell(nestedTableForCell11_Cell01);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell02);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell03);
MainTableCell11.AddElement(nestedTableForCell11);
nestedTable.AddCell(MainTableCell11);
//party name and address
//first column
PdfPCell nestedTableCell12 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
nestedTableCell12.HorizontalAlignment = 0;
nestedTableCell12.BorderWidth = 1;
nestedTableCell12.Colspan = 6;
PdfPTable nestedTableForCell12 = new PdfPTable(new float[] { 100f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 100f;
nestedTableForCell11.LockedWidth = true;
nestedTableForCell12.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell12_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Party Name :" + PartyName + " ", MainTextRegular));
nestedTableForCell12_Cell01.HorizontalAlignment = 0;
nestedTableForCell12_Cell01.BorderWidth = 0;
nestedTableForCell12.AddCell(nestedTableForCell12_Cell01);
nestedTableCell12.AddElement(nestedTableForCell12);
nestedTable.AddCell(nestedTableCell12);
PdfPCell nestedTableCell14 = new PdfPCell(new iTextSharp.text.Paragraph("Sr.No", MainTextRegularBold));
nestedTableCell14.HorizontalAlignment = 1;
nestedTableCell14.BorderWidth = 1;
PdfPCell nestedTableCell15 = new PdfPCell(new iTextSharp.text.Paragraph("Product", MainTextRegularBold));
nestedTableCell15.HorizontalAlignment = 1;
nestedTableCell15.BorderWidth = 1;
PdfPCell nestedTableCell16 = new PdfPCell(new iTextSharp.text.Paragraph("Rate", MainTextRegularBold));
nestedTableCell16.HorizontalAlignment = 1;
nestedTableCell16.BorderWidth = 1;
PdfPCell nestedTableCell17 = new PdfPCell(new iTextSharp.text.Paragraph("Qantity", MainTextRegularBold));
nestedTableCell17.HorizontalAlignment = 2;
nestedTableCell17.BorderWidth = 1;
PdfPCell nestedTableCell18 = new PdfPCell(new iTextSharp.text.Paragraph("No OF Box ", MainTextRegularBold));
nestedTableCell18.HorizontalAlignment = 2;
nestedTableCell18.BorderWidth = 1;
PdfPCell nestedTableCell19 = new PdfPCell(new iTextSharp.text.Paragraph("Amount", MainTextRegularBold));
nestedTableCell19.HorizontalAlignment = 2;
nestedTableCell19.BorderWidth = 1;
nestedTable.AddCell(nestedTableCell14);
nestedTable.AddCell(nestedTableCell15);
nestedTable.AddCell(nestedTableCell16);
nestedTable.AddCell(nestedTableCell17);
nestedTable.AddCell(nestedTableCell18);
nestedTable.AddCell(nestedTableCell19);
PdfPCell nestedTableCell_20 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_20.HorizontalAlignment = 1;
nestedTableCell_20.BorderWidthTop = 0;
nestedTableCell_20.BorderWidthLeft = 0;
nestedTableCell_20.BorderWidthRight = 1;
nestedTableCell_20.BorderWidthBottom = 1;
PdfPCell nestedTableCell_21 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_21.HorizontalAlignment = 1;
nestedTableCell_21.BorderWidthTop = 0;
nestedTableCell_21.BorderWidthLeft = 0;
nestedTableCell_21.BorderWidthRight = 1;
nestedTableCell_21.BorderWidthBottom = 1;
PdfPCell nestedTableCell_22 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_22.HorizontalAlignment = 1;
nestedTableCell_22.BorderWidthTop = 0;
nestedTableCell_22.BorderWidthLeft = 0;
nestedTableCell_22.BorderWidthRight = 1;
nestedTableCell_22.BorderWidthBottom = 1;
PdfPCell nestedTableCell_23 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_23.HorizontalAlignment = 2;
nestedTableCell_23.BorderWidthTop = 0;
nestedTableCell_23.BorderWidthLeft = 0;
nestedTableCell_23.BorderWidthRight = 1;
nestedTableCell_23.BorderWidthBottom = 1;
PdfPCell nestedTableCell_24 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_24.HorizontalAlignment = 2;
nestedTableCell_24.BorderWidthTop = 0;
nestedTableCell_24.BorderWidthLeft = 0;
nestedTableCell_24.BorderWidthRight = 0;
nestedTableCell_24.BorderWidthBottom = 1;
PdfPCell nestedTableCell_25 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_25.HorizontalAlignment = 2;
nestedTableCell_25.BorderWidthTop = 0;
nestedTableCell_25.BorderWidthLeft = 1;
nestedTableCell_25.BorderWidthRight = 1;
nestedTableCell_25.BorderWidthBottom = 1;
nestedTable.AddCell(nestedTableCell_20);
nestedTable.AddCell(nestedTableCell_21);
nestedTable.AddCell(nestedTableCell_22);
nestedTable.AddCell(nestedTableCell_23);
nestedTable.AddCell(nestedTableCell_24);
nestedTable.AddCell(nestedTableCell_25);
//calculation i.e discount, vat ***********************
PdfPCell nestedTableCell20_1 = new PdfPCell(new iTextSharp.text.Paragraph("\nTOTAL\n\n", MainTextRegularBold));
nestedTableCell20_1.HorizontalAlignment = 1;
nestedTableCell20_1.Colspan = 3;
nestedTableCell20_1.BorderWidthTop = 0;
nestedTableCell20_1.BorderWidthLeft = 1;
nestedTableCell20_1.BorderWidthRight = 1;
nestedTableCell20_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell23_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalQuantity + "\n\n", MainTextRegularSmall));
nestedTableCell23_1.HorizontalAlignment = 2;
nestedTableCell23_1.BorderWidthBottom = 0;
nestedTableCell23_1.BorderWidthTop = 0;
nestedTableCell23_1.BorderWidthLeft = 0;
nestedTableCell23_1.BorderWidthRight = 1;
PdfPCell nestedTableCell24_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalBoxes + "\n\n", MainTextRegularSmall));
nestedTableCell24_1.HorizontalAlignment = 2;
nestedTableCell24_1.BorderWidth = 1;
nestedTableCell24_1.BorderWidthTop = 0;
nestedTableCell24_1.BorderWidthLeft = 0;
nestedTableCell24_1.BorderWidthRight = 0;
nestedTableCell24_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell25_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + ItemTotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell25_1.HorizontalAlignment = 2;
nestedTableCell25_1.BorderWidth = 1;
nestedTableCell25_1.BorderWidthTop = 0;
nestedTableCell25_1.BorderWidthLeft = 1;
nestedTableCell25_1.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell20_1);
nestedTable.AddCell(nestedTableCell23_1);
nestedTable.AddCell(nestedTableCell24_1);
nestedTable.AddCell(nestedTableCell25_1);
PdfPCell nestedTableCell26 = new PdfPCell(new iTextSharp.text.Paragraph("Total Amount in words:" + AmountInWords + "", MainTextRegularSmall));
nestedTableCell26.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableCell26.Colspan = 4;
//nestedTableCell26.Rowspan = 4;
nestedTableCell26.BorderWidthTop = 1;
nestedTableCell26.BorderWidthLeft = 1;
nestedTableCell26.BorderWidthRight = 1;
nestedTableCell26.BorderWidthBottom = 0;
PdfPCell nestedTableCell28 = new PdfPCell(new iTextSharp.text.Paragraph("\n(-)Discount " + DiscountRate + "%\n\n", MainTextRegularSmall));
nestedTableCell28.HorizontalAlignment = 2;
nestedTableCell28.BorderWidthLeft = 0;
nestedTableCell28.BorderWidthRight = 0;
nestedTableCell28.BorderWidthBottom = 0;
nestedTableCell28.BorderWidthTop = 1;
PdfPCell nestedTableCell29 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + DiscountAmount + "\n\n", MainTextRegularSmall));
nestedTableCell29.HorizontalAlignment = 2;
nestedTableCell29.BorderWidth = 1;
nestedTableCell29.BorderWidthRight = 1;
nestedTableCell29.BorderWidthBottom = 0;
nestedTableCell29.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTableCell26);
nestedTable.AddCell(nestedTableCell28);
nestedTable.AddCell(nestedTableCell29);
PdfPCell nestedTable_Cell30 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTable_Cell30.HorizontalAlignment = 2;
nestedTable_Cell30.BorderWidthTop = 1;
nestedTable_Cell30.BorderWidthRight = 1;
nestedTable_Cell30.BorderWidthBottom = 0;
nestedTable_Cell30.BorderWidthLeft = 1;
nestedTable_Cell30.Colspan = 4;
nestedTable_Cell30.Rowspan = 2;
PdfPTable nestedTableFornestedTable_Cell30 = new PdfPTable(new float[] { 50f, 50f });
nestedTableFornestedTable_Cell30.TotalWidth = 278f;
nestedTableFornestedTable_Cell30.LockedWidth = true;
nestedTableFornestedTable_Cell30.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableFornestedTable_Cell30.SpacingBefore = 2f;
nestedTableFornestedTable_Cell30.SpacingAfter = 4f;
Phrase pBVatTin = new Phrase();
Chunk c1 = new Chunk("Buyer's VAT Tin", MainTextRegularSmallBold);
Chunk c2 = new Chunk(": " + BuyersVatTinNo + "\n", MainTextRegularSmall);
pBVatTin.Add(c1);
pBVatTin.Add(c2);
PdfPCell nestedTableFornestedTable_Cell30_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
nestedTableFornestedTable_Cell30_Cell01.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthTop = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell01.AddElement(pBVatTin);
Phrase pBCstTin = new Phrase();
Chunk c3 = new Chunk("Buyer's CST Tin", MainTextRegularSmallBold);
Chunk c4 = new Chunk(": " + BuyersCstTinNo + "", MainTextRegularSmall);
pBCstTin.Add(c3);
pBCstTin.Add(c4);
PdfPCell nestedTableFornestedTable_Cell30_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell02.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidth = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell02.AddElement(pBCstTin);
Phrase pSVatTin = new Phrase();
Chunk c5 = new Chunk("Seller's VAT Tin", MainTextRegularSmallBold);
Chunk c6 = new Chunk(": " + SellerVatTinNo + "", MainTextRegularSmall);
pSVatTin.Add(c5);
pSVatTin.Add(c6);
PdfPCell nestedTableFornestedTable_Cell30_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell03.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthTop = 1;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell03.AddElement(pSVatTin);
Phrase pSCstTin = new Phrase();
Chunk c7 = new Chunk("Seller's CST Tin", MainTextRegularSmallBold);
Chunk c8 = new Chunk(": " + SellerCstTinNo + "", MainTextRegularSmall);
pSCstTin.Add(c7);
pSCstTin.Add(c8);
PdfPCell nestedTableFornestedTable_Cell30_Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell04.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthTop = 1;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell04.AddElement(pSCstTin);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell01);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell02);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell03);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell04);
nestedTable_Cell30.AddElement(nestedTableFornestedTable_Cell30);
PdfPCell nestedTableCell30 = new PdfPCell(new iTextSharp.text.Paragraph("Total ", MainTextRegularSmall));
nestedTableCell30.HorizontalAlignment = 2;
nestedTableCell30.VerticalAlignment = Element.ALIGN_MIDDLE;
nestedTableCell30.BorderWidthTop = 1;
nestedTableCell30.BorderWidthRight = 0;
nestedTableCell30.BorderWidthBottom = 1;
nestedTableCell30.BorderWidthLeft = 0;
PdfPCell nestedTableCell31 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + WithDicoount_TotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell31.HorizontalAlignment = 2;
nestedTableCell31.BorderWidthTop = 1;
nestedTableCell31.BorderWidthRight = 1;
nestedTableCell31.BorderWidthBottom = 1;
nestedTableCell31.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTable_Cell30);
nestedTable.AddCell(nestedTableCell30);
nestedTable.AddCell(nestedTableCell31);
PdfPCell nestedTable_Cell32 = new PdfPCell(new iTextSharp.text.Paragraph(" I/We hereby certify that my/our registration certificate under the Maharashtra Value Addess Tax Act.2002 is in force on the date on which the sale of goods specified in this 'Tax Invoice' is made by me/us and that the transaction of sale covered by this 'Tax Invoice' has been effected by me/us and it shall be accounted for in the turn over of sales while fililng return and due tax, if any payable on the sales has been paid shall be paid.\n\n\n\n\n*T&c apply", MainTextRegularSmall));
nestedTable_Cell32.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
nestedTable_Cell32.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell32.BorderWidthTop = 1;
nestedTable_Cell32.BorderWidthRight = 1;
nestedTable_Cell32.BorderWidthBottom = 0;
nestedTable_Cell32.BorderWidthLeft = 1;
nestedTable_Cell32.Colspan = 4;
nestedTable_Cell32.Rowspan = 5;
PdfPCell nestedTableCell32 = new PdfPCell(new iTextSharp.text.Paragraph("\n(+)Vat " + VatRate + "%\n\n", MainTextRegularSmall));
nestedTableCell32.HorizontalAlignment = 2;
nestedTableCell32.BorderWidthTop = 0;
nestedTableCell32.BorderWidthRight = 0;
nestedTableCell32.BorderWidthBottom = 0;
nestedTableCell32.BorderWidthLeft = 0;
PdfPCell nestedTableCell33 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + VatAmount + "\n\n", MainTextRegularSmall));
nestedTableCell33.HorizontalAlignment = 2;
nestedTableCell33.BorderWidthTop = 0;
nestedTableCell33.BorderWidthRight = 1;
nestedTableCell33.BorderWidthBottom = 0;
nestedTableCell33.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTableCell32);
nestedTable.AddCell(nestedTableCell33);
PdfPCell nestedTableCell34 = new PdfPCell(new iTextSharp.text.Paragraph("GrandTotal", MainTextRegularSmall));
nestedTableCell34.HorizontalAlignment = 2;
nestedTableCell34.VerticalAlignment = Element.ALIGN_MIDDLE;
nestedTableCell34.BorderWidthTop = 1;
nestedTableCell34.BorderWidthRight = 0;
nestedTableCell34.BorderWidthBottom = 1;
nestedTableCell34.BorderWidthLeft = 0;
PdfPCell nestedTableCell35 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + WithVat_GrandTotal + "\n\n", MainTextRegularSmall));
nestedTableCell35.HorizontalAlignment = 2;
nestedTableCell35.BorderWidthTop = 1;
nestedTableCell35.BorderWidthRight = 1;
nestedTableCell35.BorderWidthBottom = 1;
nestedTableCell35.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTable_Cell32);
nestedTable.AddCell(nestedTableCell34);
nestedTable.AddCell(nestedTableCell35);
PdfPCell nestedTableCell37 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularBold));
nestedTableCell37.HorizontalAlignment = 0;
nestedTableCell37.BorderWidth = 1;
nestedTableCell37.Colspan = 3;
PdfPCell nestedTableCell38 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell38.HorizontalAlignment = 2;
nestedTableCell38.BorderWidth = 0;
nestedTableCell38.Colspan = 4;
PdfPTable nestedTableForCell38 = new PdfPTable(new float[] { 100f });
nestedTableForCell38.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell38.TotalWidth = 400f;
nestedTableForCell38.LockedWidth = true;
nestedTableForCell38.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell38Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularBold));
nestedTableForCell38Cell01.HorizontalAlignment = 0;
nestedTableForCell38Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularExtraSmall));//terms 1. RATES ARE QUOTED EX-FACTORY BASIS.
nestedTableForCell38Cell02.HorizontalAlignment = 0;
nestedTableForCell38Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("2. VAT TAX 5%, TRANSPORT AND OCTROI WILL BE CHARGED EXTRA IF APPLICABLE.", MainTextRegularExtraSmall));
nestedTableForCell38Cell03.HorizontalAlignment = 0;
nestedTableForCell38Cell03.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell04 = new PdfPCell(new iTextSharp.text.Paragraph("3. GOODS WILL BE DISPATCHED WITHIN 8 DAYS AFTER RECEIVING COMPLETE PAYMENT WITH PO.", MainTextRegularExtraSmall));
nestedTableForCell38Cell04.HorizontalAlignment = 0;
nestedTableForCell38Cell04.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("4. REPLACEMENT AND UNSOLD MATERIAL WILL NOT BE TAKEN BACK OR INTERTAINED.", MainTextRegularExtraSmall));
nestedTableForCell38Cell05.HorizontalAlignment = 0;
nestedTableForCell38Cell05.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell06 = new PdfPCell(new iTextSharp.text.Paragraph("5. CHANGES IN PRICE LIST RESERVED WITH THE COMPANY.", MainTextRegularExtraSmall));
nestedTableForCell38Cell06.HorizontalAlignment = 0;
nestedTableForCell38Cell06.BorderWidth = 0;
nestedTableForCell38.AddCell(nestedTableForCell38Cell01);
nestedTable.AddCell(nestedTableCell38);
PdfPCell nestedTableCell39 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmallBold));
nestedTableCell39.HorizontalAlignment = 2;
nestedTableCell39.BorderWidth = 0;
nestedTableCell39.Colspan = 2;
nestedTable.AddCell(nestedTableCell39);
PdfPCell nestedTableCell40 = new PdfPCell(new iTextSharp.text.Paragraph("\n\n\n(Propritor/Auth. Signature)", MainTextRegularSmallBold));
nestedTableCell40.HorizontalAlignment = 2;
nestedTableCell40.BorderWidth = 0;
nestedTableCell40.Colspan = 2;
nestedTable.AddCell(nestedTableCell40);
MainTableCell1.AddElement(nestedTable);
MainTable.AddCell(MainTableCell1);
//print main data is over
MasterMainTable_Cell01.AddElement(MainTable);
MasterMainTable_Cell02.AddElement(MainTable);
MasterMainTable.AddCell(MasterMainTable_Cell01);
MasterMainTable.AddCell(MasterMainTable_SpaceCell);
MasterMainTable.AddCell(MasterMainTable_Cell02);
pdfDoc.Add(MasterMainTable);
pdfDoc.Close();
//HttpContext.Current.Response.ContentType = "application/pdf";
//HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
//HttpContext.Current.Response.Write(pdfDoc);
//HttpContext.Current.Response.End();
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=abc.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
protected void btnPrint_Click(object sender, EventArgs e)
{
PrintBill();
}
}