使用IText创建Pdf文档#

时间:2011-04-25 07:06:09

标签: c# itext

如何创建包含表格的pdf文档,如下所示。

enter image description here

6 个答案:

答案 0 :(得分:10)

添加命名空间:

using iTextSharp.text;
using iTextSharp.text.pdf;

代码使用c#:

    Document doc = new Document(PageSize.A4);
    var output = new FileStream(Server.MapPath("MyFirstPDF.pdf"), FileMode.Create);
    var writer = PdfWriter.GetInstance(doc, output);


    doc.Open();


    var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/ABsIS_Logo.jpg"));
    logo.SetAbsolutePosition(430, 770);
    logo.ScaleAbsoluteHeight(30);
    logo.ScaleAbsoluteWidth(70);
    doc.Add(logo);

    PdfPTable table1 = new PdfPTable(2);
    table1.DefaultCell.Border = 0;
    table1.WidthPercentage = 80;

    var titleFont = new Font(Font.FontFamily.UNDEFINED, 24);
    var subTitleFont = new Font(Font.FontFamily.UNDEFINED, 16);

    PdfPCell cell11 = new PdfPCell();
    cell11.Colspan = 1;
    cell11.AddElement(new Paragraph("ABC Traders Receipt", titleFont));

    cell11.AddElement(new Paragraph("Thankyou for shoping at ABC traders,your order details are below", subTitleFont));


    cell11.VerticalAlignment = Element.ALIGN_LEFT;

    PdfPCell cell12 = new PdfPCell();


    cell12.VerticalAlignment = Element.ALIGN_CENTER;


    table1.AddCell(cell11);

    table1.AddCell(cell12);


    PdfPTable table2 = new PdfPTable(3);

    //One row added

    PdfPCell cell21 = new PdfPCell();

    cell21.AddElement(new Paragraph("Photo Type"));

    PdfPCell cell22 = new PdfPCell();

    cell22.AddElement(new Paragraph("No. of Copies"));

    PdfPCell cell23 = new PdfPCell();

    cell23.AddElement(new Paragraph("Amount"));


    table2.AddCell(cell21);

    table2.AddCell(cell22);

    table2.AddCell(cell23);


    //New Row Added

    PdfPCell cell31 = new PdfPCell();

    cell31.AddElement(new Paragraph("Safe"));

    cell31.FixedHeight = 300.0f;

    PdfPCell cell32 = new PdfPCell();

    cell32.AddElement(new Paragraph("2"));

    cell32.FixedHeight = 300.0f;

    PdfPCell cell33 = new PdfPCell();

    cell33.AddElement(new Paragraph("20.00 * " + "2" + " = " + (20 * Convert.ToInt32("2")) + ".00"));

    cell33.FixedHeight = 300.0f;



    table2.AddCell(cell31);

    table2.AddCell(cell32);

    table2.AddCell(cell33);


    PdfPCell cell2A = new PdfPCell(table2);

    cell2A.Colspan = 2;

    table1.AddCell(cell2A);

    PdfPCell cell41 = new PdfPCell();

    cell41.AddElement(new Paragraph("Name : " + "ABC"));

    cell41.AddElement(new Paragraph("Advance : " + "advance"));

    cell41.VerticalAlignment = Element.ALIGN_LEFT;

    PdfPCell cell42 = new PdfPCell();

    cell42.AddElement(new Paragraph("Customer ID : " + "011"));

    cell42.AddElement(new Paragraph("Balance : " + "3993"));

    cell42.VerticalAlignment = Element.ALIGN_RIGHT;


    table1.AddCell(cell41);

    table1.AddCell(cell42);


    doc.Add(table1);

    doc.Close();

答案 1 :(得分:4)

你也可以看一下http://www.mikesdotnetting.com/Category/20,一些人们常常在其后面的样本

PS:AbhiRoczz ......我个人确实避免使用玫瑰花,因为他们倾向于窃取大量资源,这意味着他们会复制并粘贴,而不会给予原始所有者信任。加上网站组织严密,有一到多个广告

答案 2 :(得分:1)

查看以下使用Itext的示例。

Itext Examples for tables lists and images

您可以进一步搜索html到pdf转换器。有很多免费工具可供使用。您需要传递包含该表的html,它将返回pdf文档。我开发了一个这样的应用程序。如果你需要,请告诉我。

答案 3 :(得分:0)

          byte[] bPDF = null;
MemoryStream ms = new MemoryStream();
Document document = new Document(); //pdf document to write
   var originalpath = HostingEnvironment.MapPath("~/PDFs/");
                if (!System.IO.Directory.Exists(originalpath))
                    Directory.CreateDirectory(originalpath);
                // Create a new PdfWriter object, specifying the outputstream

                var pdfwriter = PdfWriter.GetInstance(document, ms);

                // Open the Document for writing
                document.Open();
                PdfPTable ParentTable = new PdfPTable(1);
                 ParentTable.TotalWidth = 500f;
                             ParentTable.LockedWidth = true;
                ParentTable.HorizontalAlignment = 0;
                ParentTable.ExtendLastRow = false;
                PdfPCell heading = new PdfPCell(new Phrase("", HeaderFont));
                heading.PaddingBottom = 0f;
                heading.PaddingTop = 0f;
                heading.Border = 1;
                ParentTable.AddCell(heading);
                PdfPTable dataTableCellHeaderTable = new PdfPTable(3);
                dataTableCellHeaderTable.HorizontalAlignment = 0;
                float[] widths = new float[] { 2f, 2f, 5f };
                dataTableCellHeaderTable.SetWidths(widths);
              PdfPCell cellSerialNumber = new PdfPCell(new Phrase(ScoringColoringModel.pdfFirstCellHeading, tableHeaderCellFont)) { Border = 0 };
                cellSerialNumber.PaddingTop = 7.5f;
                cellSerialNumber.PaddingBottom = 7.5f;
                cellSerialNumber.BorderColor = BaseColor.WHITE;
                cellSerialNumber.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#D3D3D3").ToArgb());
                dataTableCellHeaderTable.AddCell(cellSerialNumber);


                PdfPCell cellRegistration = new PdfPCell(new Phrase(ScoringColoringModel.pdfSecondCellHeading, tableHeaderCellFont)) { Border = PdfPCell.LEFT_BORDER };
                cellRegistration.PaddingTop = 7.5f;
                cellRegistration.PaddingBottom = 7.5f;
                cellRegistration.BorderColor = BaseColor.WHITE;
                cellRegistration.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#D3D3D3").ToArgb());
                dataTableCellHeaderTable.AddCell(cellRegistration);

                PdfPCell cellwordMark = new PdfPCell(new Phrase(ScoringColoringModel.pdfThirdCellHeading, tableHeaderCellFont)) { Border = PdfPCell.LEFT_BORDER };
                cellwordMark.PaddingTop = 7.5f;
                cellwordMark.PaddingBottom = 7.5f;
                cellwordMark.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#D3D3D3").ToArgb());
                cellwordMark.BorderColor = BaseColor.WHITE;
                dataTableCellHeaderTable.AddCell(cellwordMark);
                // to append more data create one table
                PdfPTable datatable = new PdfPTable(3);

                Font cellColor = new Font();

                foreach (DataRow dr in objDataTable.Rows)
                {

                    if (dr.ItemArray[5].ToString() == "Yellow")
                    {

                        cellColor = FontFactory.GetFont(ScoringColoringModel.pdfFontSet, 12, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#ffa800").ToArgb())); ;

                    }
                    else
                    {
                        cellColor = FontFactory.GetFont(ScoringColoringModel.pdfFontSet, 12, new BaseColor(System.Drawing.ColorTranslator.FromHtml(dr.ItemArray[5].ToString()).ToArgb())); ;
                    }

                    dataTableCellHeaderTable.AddCell(new PdfPCell(new Phrase(dr.ItemArray[0].ToString(), cellColor)) { PaddingBottom = 5, Border = 1, PaddingTop = 5 });



         dataTableCellHeaderTable.AddCell(new PdfPCell(new Phrase(dr.ItemArray[1].ToString(), cellColor)) { PaddingBottom = 5, Border = 1, PaddingTop = 5 });

                        dataTableCellHeaderTable.AddCell(new PdfPCell(new Phrase(dr.ItemArray[3].ToString(), cellColor)) { PaddingBottom = 5, Border = 1, PaddingTop = 5 });

                    }
    //Here you can add multiple table 





                  document.Add(ParentTable);
    //document.Add(ParentTable1); and add table one by one to the document 

                    document.Close();
                    bPDF = ms.ToArray();
                    // Close the writer instance

                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "attachment;filename=TrademarkSearchResult.pdf");
                    Response.BinaryWrite(bPDF);
                    Response.End();
                }`enter code here`

答案 4 :(得分:0)

使用Itext Sharp创建PDF字母

    BaseFont bf = BaseFont.CreateFont("c:/windows/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    Font fontRupee = new Font(bf, 8, Font.ITALIC);
    Font fontRupee1 = new Font(bf, 10, Font.BOLDITALIC);


    var Smallspace = FontFactory.GetFont("Calibri", 1, iTextSharp.text.Color.BLACK);
    var boldHeadFont = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Color.RED);
    var boldTableFont = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Color.BLACK);
    var TableFontSmall = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Color.BLACK);

    var TableFontmini_ARBold8Sub = FontFactory.GetFont("Arial", 11, Font.BOLD, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBoldCom = FontFactory.GetFont("Calibri", 16, Font.BOLD, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBoldComAdd = FontFactory.GetFont("Calibri", 10, Font.NORMAL, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBold82 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBold81 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_Ver = FontFactory.GetFont("Arial", 7, Font.ITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_VerBold = FontFactory.GetFont("Arial", 8, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBoldWef8 = FontFactory.GetFont("Calibri", 9, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBold8 = FontFactory.GetFont("Calibri", 8, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBold8Nor = FontFactory.GetFont("Arial", 8.5f, Font.ITALIC, iTextSharp.text.Color.BLACK);
    //var TableFontmini_ARBold8Nor = FontFactory.GetFont("Calibri", 7, Font.ITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBold8inc = FontFactory.GetFont("Calibri", 8.5f, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var TableFontmini_ARBoldRef = FontFactory.GetFont("Calibri", 9, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
    var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 10);
    var boldFont1 = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 8, Font.UNDERLINE);
    var boldFontm = FontFactory.GetFont(FontFactory.TIMES_BOLDITALIC, 9);
    //var boldFontm = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.UNDERLINE);
    //var boldFontm= FontFactory.GetFont(FontFactory.TIMES_BOLD, 10, iTextSharp.text.Font.UNDERLINE);
    var TableFontmini_Ar = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Color.BLACK);
    BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
    iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.ITALIC, iTextSharp.text.Color.BLACK);
    iTextSharp.text.Font timessmall = new iTextSharp.text.Font(bfTimes, 9, iTextSharp.text.Font.ITALIC, iTextSharp.text.Color.BLACK);


    var normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 12);
    var boldFonts = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);

    var blackListTextFont = FontFactory.GetFont("Arial", 28, Color.BLACK);
    var redListTextFont = FontFactory.GetFont("Arial", 28, Color.RED);






    rnPL.Id = Id.SelectedValue.Trim();
    rnPL.Code = Code;
    rnPL.CodeNo = CodeNo;

    DataSet ds = rnBL.GetDetilForPDF(rnPL);
    if (ds.Tables.Count > 0)
    {
        DataTable dt = ds.Tables["tbl_Basic"];
        iTextSharp.text.Document doc = new Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
       // lblHidId.Value = dt.Rows[0]["Id"].ToString();

        if (dt.Rows[0]["Id"].ToString() == "4")
        {
            FilePath = Server.MapPath("images") + "\\1.jpg";
            FilePathstamplogo = Server.MapPath("images") + "\\6.png";
        }



        if (dt.Rows[0]["Id"].ToString() == "1")
        {
            FilePath = Server.MapPath("images") + "\\2.jpg";
            FilePathslogo = Server.MapPath("images") + "\\5.png";
        }






            //iTextSharp.text.Image stamplogo = iTextSharp.text.Image.GetInstance(FilePathstamplogo);
            //stamplogo.ScalePercent(75f);

            ////stamplogo.SetAbsolutePosition(doc.PageSize.Width - 36f - 140f, doc.PageSize.Height - 36f - 640f);/*ByAbhishek*/
            //stamplogo.SetAbsolutePosition(doc.PageSize.Width - 38f - 160f, doc.PageSize.Height - 38f - 700f);
            //doc.Add(stamplogo);




        iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(FilePath);
        jpg.ScaleAbsoluteHeight(830);
        jpg.ScaleAbsoluteWidth(600);
        jpg.Alignment = iTextSharp.text.Image.UNDERLYING;
        fofile = "";
        fofile = Server.MapPath("PDFComRNew");
        string crefilename;
        crefilename = Convert.ToInt32(Code.ToString()).ToString() + Convert.ToInt32(CodeNo.ToString()).ToString() + ".Pdf";
        string newPathfile = System.IO.Path.Combine(fofile, crefilename);
        PdfWriter pdfwrite = PdfWriter.GetInstance(doc, new FileStream(newPathfile, FileMode.Create));

        doc.Open();
        doc.Add(jpg);

        PdfPTable tableHeader = new PdfPTable(1);
        tableHeader.WidthPercentage = 50;
        PdfPCell Headspace;

        Headspace = new PdfPCell(new Phrase(" ", TableFontSmall));
        Headspace.BorderWidth = 0;
        Headspace.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
        tableHeader.AddCell(Headspace);

        Headspace = new PdfPCell(new Phrase(" ", TableFontSmall));
        Headspace.BorderWidth = 0;
        Headspace.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
        tableHeader.AddCell(Headspace);



        Headspace = new PdfPCell(new Phrase(" ", TableFontSmall));
        Headspace.BorderWidth = 0;
        Headspace.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
        tableHeader.AddCell(Headspace);
        doc.Add(tableHeader);
        #endregion



        PdfPTable tblAcNo = new PdfPTable(1);
        float[] colWidthsaccingo = { 1000 };
        tblAcNo.SetWidths(colWidthsaccingo);
        PdfPCell celladdingo;

        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);
        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);

        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);

        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);


        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);

        celladdingo = new PdfPCell(new Phrase("  ", Smallspace));
        celladdingo.HorizontalAlignment = 1;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 2;
        tblAcNo.AddCell(celladdingo);

        celladdingo = new PdfPCell(new Phrase(" ", TableFontmini_ARBold8));
        celladdingo.HorizontalAlignment = 0;
        celladdingo.BorderWidth = 0;
        celladdingo.Colspan = 1;
        tblAcNo.AddCell(celladdingo);

        //Chunk c111 = new Chunk("Ref No : ", TableFontmini_ARBoldRef);
        //Chunk c211 = new Chunk((dt.Rows[0]["RefrenceNo"]).ToString(), TableFontmini_ARBold8Nor);
        //Phrase p211 = new Phrase();
        //p211.Add(c111);
        //p211.Add(c211);
        Paragraph pS = new Paragraph();
        //pS.Add(p211);
        /*For gst*/
        /*For space*/
        Chunk cspc = new Chunk("                                                                                                    ", TableFontmini_ARBold8);
        Phrase pcspc = new Phrase();
        pcspc.Add(cspc);
        pS.Add(pcspc);
        /*For space*/

        /*For statecode*/
        Chunk c1111 = new Chunk("Date : ", TableFontmini_ARBoldRef);
        Chunk c2111 = new Chunk((dt.Rows[0]["GenearteDate"]).ToString(), TableFontmini_ARBold8Nor);
        Phrase p2111 = new Phrase();
        p2111.Add(c1111);
        p2111.Add(c2111);

        pS.Add(p2111);
        /*For statecode*/

        /*For finally add*/
        PdfPCell cellDet_4 = new PdfPCell(pS);
        cellDet_4.HorizontalAlignment = 0; /**Left=0,Centre=1,Right=2**/
        cellDet_4.BorderWidth = 0;
        cellDet_4.Colspan = 2;
        tblAcNo.AddCell(cellDet_4);

        doc.Add(tblAcNo);



        PdfPTable tblto = new PdfPTable(1);
        float[] colWidthTo = { 1000 };
        tblto.SetWidths(colWidthTo);
        PdfPCell cellTo;

        cellTo = new PdfPCell(new Phrase("  ", Smallspace));
        cellTo.HorizontalAlignment = 1;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 2;
        tblto.AddCell(cellTo);

        cellTo = new PdfPCell(new Phrase("  ", Smallspace));
        cellTo.HorizontalAlignment = 1;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 2;
        tblto.AddCell(cellTo);

        cellTo = new PdfPCell(new Phrase("  ", Smallspace));
        cellTo.HorizontalAlignment = 1;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 2;
        tblto.AddCell(cellTo);

        cellTo = new PdfPCell(new Phrase("  ", Smallspace));
        cellTo.HorizontalAlignment = 1;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 2;
        tblto.AddCell(cellTo);

        cellTo = new PdfPCell(new Phrase("  ", Smallspace));
        cellTo.HorizontalAlignment = 1;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 2;
        tblto.AddCell(cellTo);

        cellTo = new PdfPCell(new Phrase("To, ", TableFontmini_ARBold8Nor));
        cellTo.HorizontalAlignment = 0;
        cellTo.BorderWidth = 0;
        cellTo.Colspan = 1;
        tblto.AddCell(cellTo);

        doc.Add(tblto);



        PdfPTable tblToManager = new PdfPTable(1);
        float[] colWidthToManager = { 1000 };
        tblToManager.SetWidths(colWidthToManager);
        PdfPCell cellToManager;

        cellToManager = new PdfPCell(new Phrase("  ", Smallspace));
        cellToManager.HorizontalAlignment = 1;
        cellToManager.BorderWidth = 0;
        cellToManager.Colspan = 2;
        tblToManager.AddCell(cellToManager);

        cellToManager = new PdfPCell(new Phrase(" ", TableFontmini_ARBold8Nor));
        cellToManager.HorizontalAlignment = 0;
        cellToManager.BorderWidth = 0;
        cellToManager.Colspan = 1;
        tblToManager.AddCell(cellToManager);
        doc.Add(tblToManager);

        PdfPTable tblBillHead = new PdfPTable(1);
        float[] colWidthBillHead = { 1000 };
        tblBillHead.SetWidths(colWidthBillHead);

        PdfPCell celltblBillHead = new PdfPCell(new Paragraph(dt.Rows[0]["Header"].ToString(), TableFontmini_ARBold8));
        celltblBillHead.HorizontalAlignment = 0;
        celltblBillHead.BorderWidth = 0;
        celltblBillHead.Colspan = 1;
        tblBillHead.AddCell(celltblBillHead);

        doc.Add(tblBillHead);

        PdfPTable tblSiteAdd = new PdfPTable(1);
        float[] colWidthSiteAdd = { 1000 };
        tblSiteAdd.SetWidths(colWidthSiteAdd);

        PdfPCell celltblSiteAdd = new PdfPCell(new Paragraph(dt.Rows[0]["Address"].ToString(), TableFontmini_ARBold8Nor));
        celltblSiteAdd.HorizontalAlignment = 0;
        celltblSiteAdd.BorderWidth = 0;
        celltblSiteAdd.Colspan = 1;
        tblSiteAdd.AddCell(celltblSiteAdd);

        doc.Add(tblSiteAdd);

        PdfPTable tblSiteCity = new PdfPTable(1);
        float[] colWidthSiteCity = { 1000 };
        tblSiteCity.SetWidths(colWidthSiteCity);

        PdfPCell celltblSiteCity = new PdfPCell(new Paragraph(dt.Rows[0]["City"].ToString(), TableFontmini_ARBold8));
        celltblSiteCity.HorizontalAlignment = 0;
        celltblSiteCity.BorderWidth = 0;
        celltblSiteCity.Colspan = 1;
        tblSiteCity.AddCell(celltblSiteCity);
        doc.Add(tblSiteCity);



        PdfPTable tblSubject = new PdfPTable(1);
        float[] colWidthSubject = { 1000 };
        tblSubject.SetWidths(colWidthSubject);
        PdfPCell cellSubject;

        cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
        cellSubject.HorizontalAlignment = 1;
        cellSubject.BorderWidth = 0;
        cellSubject.Colspan = 2;
        tblSubject.AddCell(cellSubject);

        cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
        cellSubject.HorizontalAlignment = 1;
        cellSubject.BorderWidth = 0;
        cellSubject.Colspan = 2;
        tblSubject.AddCell(cellSubject);


        cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
        cellSubject.HorizontalAlignment = 1;
        cellSubject.BorderWidth = 0;
        cellSubject.Colspan = 2;
        tblSubject.AddCell(cellSubject);

        cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
        cellSubject.HorizontalAlignment = 1;
        cellSubject.BorderWidth = 0;
        cellSubject.Colspan = 2;
        tblSubject.AddCell(cellSubject);

        cellSubject = new PdfPCell(new Phrase("   Sub.: Application For leave", TableFontmini_ARBold8Sub));
        cellSubject.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
        cellSubject.BorderWidth = 0;
        cellSubject.Colspan = 1;
        tblSubject.AddCell(cellSubject);

        doc.Add(tblSubject);



        PdfPTable tblDEarSir = new PdfPTable(1);
        float[] colWidthDEarSir = { 1000 };
        tblDEarSir.SetWidths(colWidthDEarSir);
        PdfPCell cellDEarSir;

        cellDEarSir = new PdfPCell(new Phrase("  ", Smallspace));
        cellDEarSir.HorizontalAlignment = 1;
        cellDEarSir.BorderWidth = 0;
        cellDEarSir.Colspan = 2;
        tblDEarSir.AddCell(cellDEarSir);

        cellDEarSir = new PdfPCell(new Phrase("  ", Smallspace));
        cellDEarSir.HorizontalAlignment = 1;
        cellDEarSir.BorderWidth = 0;
        cellDEarSir.Colspan = 2;
        tblDEarSir.AddCell(cellDEarSir);

        cellDEarSir = new PdfPCell(new Phrase("  ", Smallspace));
        cellDEarSir.HorizontalAlignment = 1;
        cellDEarSir.BorderWidth = 0;
        cellDEarSir.Colspan = 2;
        tblDEarSir.AddCell(cellDEarSir);

        cellDEarSir = new PdfPCell(new Phrase("Dear Sir, ", TableFontmini_ARBold8));
        cellDEarSir.HorizontalAlignment = 0;
        cellDEarSir.BorderWidth = 0;
        cellDEarSir.Colspan = 1;
        tblDEarSir.AddCell(cellDEarSir);
        doc.Add(tblDEarSir);

        PdfPTable tblPara1 = new PdfPTable(1);
        float[] colWidthPara1 = { 1200 };
        tblPara1.SetWidths(colWidthPara1);
        PdfPCell cellPara1;

        cellPara1 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara1.HorizontalAlignment = 1;
        cellPara1.BorderWidth = 0;
        cellPara1.Colspan = 4;
        tblPara1.AddCell(cellPara1);

        cellPara1 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara1.HorizontalAlignment = 1;
        cellPara1.BorderWidth = 0;
        cellPara1.Colspan = 4;
        tblPara1.AddCell(cellPara1);

        cellPara1 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara1.HorizontalAlignment = 1;
        cellPara1.BorderWidth = 0;
        cellPara1.Colspan = 4;
        tblPara1.AddCell(cellPara1);

        cellPara1 = new PdfPCell(new Paragraph("i beg to say that i m feelling unwell", TableFontmini_ARBold8Nor));
        cellPara1.HorizontalAlignment = 3;
        cellPara1.BorderWidth = 0;
        cellPara1.Colspan = 1;
        tblPara1.AddCell(cellPara1);
        doc.Add(tblPara1);

        PdfPTable tblPara2 = new PdfPTable(1);
        float[] colWidthPara2 = { 1400 };
        tblPara2.SetWidths(colWidthPara2);
        PdfPCell cellPara2;

        cellPara2 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara2.HorizontalAlignment = 1;
        cellPara2.BorderWidth = 0;
        cellPara2.Colspan = 4;
        tblPara2.AddCell(cellPara2);
        cellPara2 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara2.HorizontalAlignment = 1;
        cellPara2.BorderWidth = 0;
        cellPara2.Colspan = 4;
        tblPara2.AddCell(cellPara2);

        cellPara2 = new PdfPCell(new Paragraph("Kindly give me leave for four days ", TableFontmini_ARBold8Nor));
        cellPara2.HorizontalAlignment = 3;
        cellPara2.BorderWidth = 0;
        cellPara2.Colspan = 1;

        tblPara2.AddCell(cellPara2);

        doc.Add(tblPara2);

        PdfPTable tblPara3 = new PdfPTable(1);
        float[] colWidthPara3 = { 1200 };
        tblPara3.SetWidths(colWidthPara3);
        PdfPCell cellPara3;
        cellPara3 = new PdfPCell(new Phrase("  ", Smallspace));
        cellPara3.HorizontalAlignment = 1;
        cellPara3.BorderWidth = 0;
        cellPara3.Colspan = 4;
        tblPara3.AddCell(cellPara3);

        cellPara3 = new PdfPCell(new Paragraph(" from Date" + dt.Rows[0]["Date"].ToString(), TableFontmini_ARBold8Nor));
        cellPara3.HorizontalAlignment = 3;
        cellPara3.BorderWidth = 0;
        cellPara3.Colspan = 1;
        tblPara3.AddCell(cellPara3);
        doc.Add(tblPara3);

        PdfPTable tblLastPara = new PdfPTable(1);
        float[] colWidthLastPara = { 1200 };
        tblPara1.SetWidths(colWidthLastPara);
        PdfPCell cellLastPara;

        cellLastPara = new PdfPCell(new Phrase("  ", Smallspace));
        cellLastPara.HorizontalAlignment = 1;
        cellLastPara.BorderWidth = 0;
        cellLastPara.Colspan = 2;
        tblLastPara.AddCell(cellLastPara);

        cellLastPara = new PdfPCell(new Phrase("  ", Smallspace));
        cellLastPara.HorizontalAlignment = 1;
        cellLastPara.BorderWidth = 0;
        cellLastPara.Colspan = 2;
        tblLastPara.AddCell(cellLastPara);

        cellLastPara = new PdfPCell(new Phrase("  ", Smallspace));
        cellLastPara.HorizontalAlignment = 1;
        cellLastPara.BorderWidth = 0;
        cellLastPara.Colspan = 2;
        tblLastPara.AddCell(cellLastPara);

        cellLastPara = new PdfPCell(new Paragraph("Thank you so much for giving me leave", TableFontmini_ARBold8Nor));
        cellLastPara.HorizontalAlignment = 3;
        cellLastPara.BorderWidth = 0;
        cellLastPara.Colspan = 1;
        tblLastPara.AddCell(cellLastPara);
        doc.Add(tblLastPara);

        PdfPTable tblThankingYou = new PdfPTable(1);
        float[] colWidthThankingYou = { 1000 };
        tblSiteCity.SetWidths(colWidthSiteCity);
        PdfPCell celltblThankingYou;

        celltblThankingYou = new PdfPCell(new Phrase("  ", Smallspace));
        celltblThankingYou.HorizontalAlignment = 1;
        celltblThankingYou.BorderWidth = 0;
        celltblThankingYou.Colspan = 2;
        tblThankingYou.AddCell(celltblThankingYou);

        celltblThankingYou = new PdfPCell(new Phrase("  ", Smallspace));
        celltblThankingYou.HorizontalAlignment = 1;
        celltblThankingYou.BorderWidth = 0;
        celltblThankingYou.Colspan = 2;
        tblThankingYou.AddCell(celltblThankingYou);

        celltblThankingYou = new PdfPCell(new Phrase("  ", Smallspace));
        celltblThankingYou.HorizontalAlignment = 1;
        celltblThankingYou.BorderWidth = 0;
        celltblThankingYou.Colspan = 2;
        tblThankingYou.AddCell(celltblThankingYou);

        celltblThankingYou = new PdfPCell(new Paragraph("Thanking You,", TableFontmini_ARBold8Nor));
        celltblThankingYou.HorizontalAlignment = 0;
        celltblThankingYou.BorderWidth = 0;
        celltblThankingYou.Colspan = 1;
        tblThankingYou.AddCell(celltblThankingYou);
        doc.Add(tblThankingYou);

        PdfPTable tblYorsSinc = new PdfPTable(1);
        float[] colWidthYorsSinc = { 1000 };
        tblYorsSinc.SetWidths(colWidthYorsSinc);
        PdfPCell cellYorsSinc;

        cellYorsSinc = new PdfPCell(new Phrase("  ", Smallspace));
        cellYorsSinc.HorizontalAlignment = 1;
        cellYorsSinc.BorderWidth = 0;
        cellYorsSinc.Colspan = 2;
        tblYorsSinc.AddCell(cellYorsSinc);

        cellYorsSinc = new PdfPCell(new Paragraph("Sincerely Yours,", TableFontmini_ARBold8Nor));
        cellYorsSinc.HorizontalAlignment = 0;
        cellYorsSinc.BorderWidth = 0;
        cellYorsSinc.Colspan = 1;
        tblYorsSinc.AddCell(cellYorsSinc);
        doc.Add(tblYorsSinc);

        PdfPTable tblAuthSignat = new PdfPTable(1);
        float[] colWidthAuthSignat = { 1000 };
        tblAuthSignat.SetWidths(colWidthAuthSignat);
        PdfPCell cellAuthSignat;

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);
        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;

        cellAuthSignat = new PdfPCell(new Phrase("  ", Smallspace));
        cellAuthSignat.HorizontalAlignment = 1;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 2;
        tblAuthSignat.AddCell(cellAuthSignat);
        tblAuthSignat.AddCell(cellAuthSignat);

        cellAuthSignat = new PdfPCell(new Paragraph("(Student Signatature)", TableFontmini_ARBold8));
        cellAuthSignat.HorizontalAlignment = 0;
        cellAuthSignat.BorderWidth = 0;
        cellAuthSignat.Colspan = 1;
        tblAuthSignat.AddCell(cellAuthSignat);
        doc.Add(tblAuthSignat);

        PdfPTable tblForCom = new PdfPTable(1);
        float[] colWidthForCom = { 1000 };
        tblYorsSinc.SetWidths(colWidthForCom);
        PdfPCell cellForCom;

        cellForCom = new PdfPCell(new Phrase("  ", Smallspace));
        cellForCom.HorizontalAlignment = 1;
        cellForCom.BorderWidth = 0;
        cellForCom.Colspan = 2;
        tblForCom.AddCell(cellForCom);

        cellForCom = new PdfPCell(new Paragraph("For  " + dt.Rows[0]["Name"].ToString(), TableFontmini_ARBold8));
        cellForCom.HorizontalAlignment = 0;
        cellForCom.BorderWidth = 0;
        cellForCom.Colspan = 1;
        tblForCom.AddCell(cellForCom);
        doc.Add(tblForCom);



            pdfwrite.PageEvent = new FooterRN(dt.Rows[0]["Address"].ToString(), Convert.ToInt32(Code.ToString()).ToString(), dt.Rows[0]["Id"].ToString(), dt.Rows[0]["Studentmail"].ToString(), dt.Rows[0]["PhoneNo1"].ToString(), dt.Rows[0]["StudentName"].ToString());


        doc.Close();
    }

答案 5 :(得分:0)

private void FormPage(string Code)
    {
        #region For Set Pdf FontSize,FontStyle FontColor etc..!!
        #region for rs font
        BaseFont bf = BaseFont.CreateFont("c:/windows/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font fontRupee = new Font(bf, 8, Font.ITALIC);
        Font fontRupee1 = new Font(bf, 10, Font.BOLDITALIC);
        #endregion

        #region My Project
        var Smallspace = FontFactory.GetFont("Calibri", 1, iTextSharp.text.BaseColor.BLACK);
        var boldHeadFont = FontFactory.GetFont("Calibri", 13, iTextSharp.text.BaseColor.RED);
        var boldTableFont = FontFactory.GetFont("Calibri", 11, iTextSharp.text.BaseColor.BLACK);
        var TableFontSmall = FontFactory.GetFont("Calibri", 8, iTextSharp.text.BaseColor.BLACK);


        var TableFontmini_ARBold82 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold81 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_Ver = FontFactory.GetFont("Arial", 7, Font.ITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_VerBold = FontFactory.GetFont("Calibri", 8, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold10 = FontFactory.GetFont("Arial", 10, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);

        var TableFontmini_GorBold12 = FontFactory.GetFont("Georgia", 12, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold12 = FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold11 = FontFactory.GetFont("Arial", 11, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold8Nor = FontFactory.GetFont("Arial", 9, Font.ITALIC, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBold8inc = FontFactory.GetFont("Calibri", 8.5f, Font.BOLD, iTextSharp.text.BaseColor.BLACK);
        var TableFontmini_ARBoldRef = FontFactory.GetFont("Calibri", 9, Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK);
        var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 10);
        var boldFont1 = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 9, Font.BOLD);
        var boldFontm = FontFactory.GetFont(FontFactory.TIMES_BOLDITALIC, 9);

        var boldFontTax = FontFactory.GetFont(FontFactory.TIMES_BOLDITALIC, 9, Font.UNDERLINE);

        var TableFontmini_Ar = FontFactory.GetFont("Calibri", 8, iTextSharp.text.BaseColor.BLACK);
        BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
        iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.ITALIC, iTextSharp.text.BaseColor.BLACK);
        iTextSharp.text.Font timessmall = new iTextSharp.text.Font(bfTimes, 9, iTextSharp.text.Font.ITALIC, iTextSharp.text.BaseColor.BLACK);
        #endregion

        #region server

        //var Smallspace = FontFactory.GetFont("Calibri", 1, iTextSharp.text.Color.BLACK);
        //var boldHeadFont = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Color.RED);
        //var boldTableFont = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Color.BLACK);
        //var TableFontSmall = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Color.BLACK);


        //var TableFontmini_ARBold82 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold81 = FontFactory.GetFont("Tahoma", 7, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
        //var TableFontmini_Ver = FontFactory.GetFont("Arial", 7, Font.ITALIC, iTextSharp.text.Color.BLACK);
        //var TableFontmini_VerBold = FontFactory.GetFont("Calibri", 8, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold10 = FontFactory.GetFont("Arial", 10, Font.BOLD, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold12 = FontFactory.GetFont("Arial", 12, Font.BOLD, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold11 = FontFactory.GetFont("Arial", 11, Font.BOLD, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold8Nor = FontFactory.GetFont("Arial", 9, Font.NORMAL, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBold8inc = FontFactory.GetFont("Calibri", 8.5f, Font.BOLD, iTextSharp.text.Color.BLACK);
        //var TableFontmini_ARBoldRef = FontFactory.GetFont("Calibri", 9, Font.BOLDITALIC, iTextSharp.text.Color.BLACK);
        //var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 10);
        //var boldFont1 = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 9, Font.BOLD);
        //var boldFontm = FontFactory.GetFont(FontFactory.TIMES_BOLDITALIC, 9);

        //var boldFontTax = FontFactory.GetFont(FontFactory.TIMES_BOLDITALIC, 9, Font.UNDERLINE);

        //var TableFontmini_Ar = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Color.BLACK);
        //BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
        //iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.ITALIC, iTextSharp.text.Color.BLACK);
        //iTextSharp.text.Font timessmall = new iTextSharp.text.Font(bfTimes, 9, iTextSharp.text.Font.ITALIC, iTextSharp.text.Color.BLACK);
        #endregion

        #endregion


        #region For Get All Records..!!


        CPL.EmpCode = Code;
        CPL.ForFormEleven = "1";
         DataTable dt = CBL.GetEmpDetailForPDF(CPL);
        if (dt.Rows.Count > 0)
        {
                       
            iTextSharp.text.Document doc = new Document(iTextSharp.text.PageSize.A4, 5f, 5f, 5f, 5f);
            #region For PDF File And PDF Folder..!!
            FilePath = Server.MapPath("Billinglatestimages") + "\\Cash.jpg";
            #endregion
            #region For PDF File And PDF Folder..!!
            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(FilePath);
            jpg.ScaleAbsoluteHeight(1600);
            jpg.ScaleAbsoluteWidth(900);
            jpg.Alignment = iTextSharp.text.Image.UNDERLYING;

            #region New Writing region
            string dbfileName = null;/*This varialble is Used for storing the filenames in database.*/
            string DocPath = null;/*This varialble is Used for Craetting  the File path .*/
            DocPath = Server.MapPath("~/HRD/EmpFormEleven/") + "/";
            //DocPath = Server.MapPath("~/HRD/SiteWiseHRLetter/") + HidSiteCode.Value + "/" + hidLetterId.Value + "/";
            if (!(Directory.Exists(DocPath)))
            {
                Directory.CreateDirectory(DocPath);
            }
            fofile1 = "";
            fofile1 = DocPath;
            string crefilename1;
            crefilename1 = Convert.ToInt32(InvoiceNo.ToString()).ToString() +"_1" +".Pdf";
            string newPathfile1 = System.IO.Path.Combine(fofile1, crefilename1);
            PdfWriter pdfwrite1 = PdfWriter.GetInstance(doc, new FileStream(newPathfile1, FileMode.Create));
            #endregion
            doc.Open();
            doc.Add(jpg);
            #endregion

            #region PDF Header Section Start..!!
            PdfPTable tableHeader = new PdfPTable(1);
            tableHeader.WidthPercentage = 100;
            PdfPCell Headspace;
          
            Headspace = new PdfPCell(new Phrase(" ", TableFontSmall));
            Headspace.BorderWidth = 0;
            Headspace.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
            tableHeader.AddCell(Headspace);

            Headspace = new PdfPCell(new Phrase(" ", TableFontSmall));
            Headspace.BorderWidth = 0;
            Headspace.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
            tableHeader.AddCell(Headspace);
            doc.Add(tableHeader);
            #endregion

            #region For Header 1
            PdfPTable tblSubject = new PdfPTable(1);
            float[] colWidthSubject = { 1600 };
            tblSubject.SetWidths(colWidthSubject);
            PdfPCell cellSubject;

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);
            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            cellSubject = new PdfPCell(new Phrase("  ", Smallspace));
            cellSubject.HorizontalAlignment = 1;
            cellSubject.BorderWidth = 0;
            cellSubject.Colspan = 2;
            tblSubject.AddCell(cellSubject);

            PdfPCell cellSubject1 = new PdfPCell(new Paragraph("FORM No-11 (New) Declaration Form", TableFontmini_ARBold11));

            cellSubject1.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
            cellSubject1.BorderWidth = 0;
            cellSubject1.Colspan = 1;
            tblSubject.AddCell(cellSubject1);
            doc.Add(tblSubject);
            #endregion

            #region For Header2
            PdfPTable tblHeader2 = new PdfPTable(1);
            float[] colWidthHeader2 = { 1600 };
            tblHeader2.SetWidths(colWidthHeader2);
            PdfPCell cellHeader2;

            cellHeader2 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader2.HorizontalAlignment = 1;
            cellHeader2.BorderWidth = 0;
            cellHeader2.Colspan = 2;
            tblHeader2.AddCell(cellHeader2);



            cellHeader2 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader2.HorizontalAlignment = 1;
            cellHeader2.BorderWidth = 0;
            cellHeader2.Colspan = 2;
            tblHeader2.AddCell(cellHeader2);

            PdfPCell cellHeaderL = new PdfPCell(new Paragraph("(To be retained by the employer for future reference )", TableFontmini_ARBold8Nor));

            cellHeaderL.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
            cellHeaderL.BorderWidth = 0;
            cellHeaderL.Colspan = 1;
            tblHeader2.AddCell(cellHeaderL);
            doc.Add(tblHeader2);
            #endregion

            #region For Header3
            PdfPTable tblHeader3 = new PdfPTable(1);
            float[] colWidthHeader3 = { 1600 };
            tblHeader3.SetWidths(colWidthHeader3);
            PdfPCell cellHeader3;

            cellHeader3 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader3.HorizontalAlignment = 1;
            cellHeader3.BorderWidth = 0;
            cellHeader3.Colspan = 2;
            tblHeader3.AddCell(cellHeader3);


            PdfPCell cellHeader3L = new PdfPCell(new Paragraph("EMPLOYEES' PROVIDENT FUNDS ORGANISATION", TableFontmini_GorBold12));
            cellHeader3L.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
            cellHeader3L.BorderWidth = 0;
            cellHeader3L.Colspan = 1;
            tblHeader3.AddCell(cellHeader3L);
            doc.Add(tblHeader3);
            #endregion

            #region For Header4
            PdfPTable tblHeader4 = new PdfPTable(1);
            float[] colWidthHeader4 = { 1600 };
            tblHeader4.SetWidths(colWidthHeader4);
            PdfPCell cellHeader4;

            cellHeader4 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader4.HorizontalAlignment = 1;
            cellHeader4.BorderWidth = 0;
            cellHeader4.Colspan = 2;
            tblHeader4.AddCell(cellHeader4);

            PdfPCell cellHeader4L = new PdfPCell(new Paragraph("Employee's Provident Funds Scheme,1952 (Paragraph 34 & 57 ) & Employee's  Pension Scheme, 1995(Paragraph 24)", TableFontmini_ARBold10));
            cellHeader4L.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
            cellHeader4L.BorderWidth = 0;
            cellHeader4L.Colspan = 20;
            tblHeader4.AddCell(cellHeader4L);
            doc.Add(tblHeader4);
            #endregion

            #region For Header5
            PdfPTable tblHeader5 = new PdfPTable(1);
            float[] colWidthHeader5 = { 1600 };
            tblHeader5.SetWidths(colWidthHeader5);
            PdfPCell cellHeader5;

            cellHeader5 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader5.HorizontalAlignment = 1;
            cellHeader5.BorderWidth = 0;
            cellHeader5.Colspan = 2;
            tblHeader5.AddCell(cellHeader5);

            PdfPCell cellHeader5L = new PdfPCell(new Paragraph("Declaration by a person taking up employment in an establishment on which Employee's Provident Fund Scheme, 1952 and / or Employee's Pension Scheme, 1995 is applicable.", TableFontmini_ARBold10));
            cellHeader5L.HorizontalAlignment = 0;/**Left=0,Centre=1,Right=2**/
            cellHeader5L.BorderWidth = 0;
            cellHeader5L.Colspan = 20;
            tblHeader5.AddCell(cellHeader5L);
            doc.Add(tblHeader5);
            #endregion

            #region For Header6
            PdfPTable tblHeader6 = new PdfPTable(1);
            float[] colWidthHeader6 = { 1600 };
            tblHeader6.SetWidths(colWidthHeader6);
            PdfPCell cellHeader6;

            cellHeader6 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader6.HorizontalAlignment = 1;
            cellHeader6.BorderWidth = 0;
            cellHeader6.Colspan = 2;
            tblHeader6.AddCell(cellHeader6);


            PdfPCell cellHeader6L = new PdfPCell(new Paragraph("(PLEASE GO THROUGH THE INSTRUCTIONS)", TableFontmini_ARBold11));
            cellHeader6L.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
            cellHeader6L.BorderWidth = 0;
            cellHeader6L.Colspan = 1;
            tblHeader6.AddCell(cellHeader6L);
            doc.Add(tblHeader6);
            #endregion

            #region For Line Space
            PdfPTable tblHeader7 = new PdfPTable(1);
            float[] colWidthHeader7 = { 1600 };
            tblHeader7.SetWidths(colWidthHeader7);
            PdfPCell cellHeader7;

            cellHeader7 = new PdfPCell(new Phrase("  ", Smallspace));
            cellHeader7.HorizontalAlignment = 1;
            cellHeader7.BorderWidth = 0;
            cellHeader7.Colspan = 2;
            tblHeader7.AddCell(cellHeader7);


            PdfPCell cellHeader7L = new PdfPCell(new Paragraph("  ", TableFontmini_ARBold11));
            cellHeader7L.HorizontalAlignment = 1;/**Left=0,Centre=1,Right=2**/
            cellHeader7L.BorderWidth = 0;
            cellHeader7L.Colspan = 1;
            tblHeader7.AddCell(cellHeader7L);
            doc.Add(tblHeader7);
            #endregion


            #region Name..!!

            PdfPTable tblName = new PdfPTable(3);
            float[] colWidthsaccing4 = { 100, 500, 700};
            tblName.SetWidths(colWidthsaccing4);
            PdfPCell celladdingo4;
            celladdingo4 = new PdfPCell(new Phrase("  ", Smallspace));
            celladdingo4.HorizontalAlignment = 1;
            celladdingo4.BorderWidth = 0;
            celladdingo4.Colspan = 2;
            tblHeader6.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase("1.", TableFontmini_ARBold8Nor));
            celladdingo4.HorizontalAlignment = 1;
            
            celladdingo4.PaddingBottom = 5f;
            celladdingo4.BorderWidth = 0.5f;
            tblName.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase("  Name :", TableFontmini_ARBold8Nor));
            celladdingo4.HorizontalAlignment = 0;
            celladdingo4.PaddingBottom = 5f;
            celladdingo4.BorderWidth = 0.5f;
            tblName.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase(" " +dt.Rows[0]["EmpName"].ToString(), TableFontmini_ARBold8Nor));
            celladdingo4.HorizontalAlignment = 0;
            celladdingo4.PaddingBottom = 5f;
            celladdingo4.BorderWidth = 0.5f;
            tblName.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase("  ", Smallspace));
            celladdingo4.HorizontalAlignment = 1;
            celladdingo4.BorderWidth = 0;
            celladdingo4.Colspan = 2;
            tblHeader6.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase("  ", Smallspace));
            celladdingo4.HorizontalAlignment = 1;
            celladdingo4.BorderWidth = 0;
            celladdingo4.Colspan = 2;
            tblHeader6.AddCell(celladdingo4);

            celladdingo4 = new PdfPCell(new Phrase("  ", Smallspace));
            celladdingo4.HorizontalAlignment = 1;
            celladdingo4.BorderWidth = 0;
            celladdingo4.Colspan = 2;
            
            tblHeader6.AddCell(celladdingo4);


            doc.Add(tblName);

            #endregion

            #region DOB..!!

            PdfPTable tblDOB = new PdfPTable(3);
            float[] colWidthsaccingDOB = { 100, 500, 700 };
            tblDOB.SetWidths(colWidthsaccingDOB);
            PdfPCell cellDOB;
         

            cellDOB = new PdfPCell(new Phrase("2.", TableFontmini_ARBold8Nor));
            cellDOB.HorizontalAlignment = 1;

            cellDOB.PaddingBottom = 5f;
            cellDOB.BorderWidth = 0.5f;
            tblDOB.AddCell(cellDOB);

            cellDOB = new PdfPCell(new Phrase("  Date Of Birth :(DD/Mm/YYYY)", TableFontmini_ARBold8Nor));
            cellDOB.HorizontalAlignment = 0;
            cellDOB.PaddingBottom = 5f;
            cellDOB.BorderWidth = 0.5f;
            tblDOB.AddCell(cellDOB);

            cellDOB = new PdfPCell(new Phrase(" " + dt.Rows[0]["EmpDOB"].ToString(), TableFontmini_ARBold8Nor));
            cellDOB.HorizontalAlignment = 0;
            cellDOB.PaddingBottom = 5f;
            cellDOB.BorderWidth = 0.5f;
            tblDOB.AddCell(cellDOB);

           

            tblDOB.AddCell(cellDOB);
            doc.Add(tblDOB);

            #endregion

            #region tblFatherHusbandName..!!

            PdfPTable tblFatherHusbandName = new PdfPTable(3);
            float[] colWidthsaccingFatherHusbandName = { 100, 500, 700 };
            tblFatherHusbandName.SetWidths(colWidthsaccingFatherHusbandName);
            PdfPCell cellFatherHusbandName;


            cellFatherHusbandName = new PdfPCell(new Phrase("3.", TableFontmini_ARBold8Nor));
            cellFatherHusbandName.HorizontalAlignment = 1;

            cellFatherHusbandName.PaddingBottom = 5f;
            cellFatherHusbandName.BorderWidth = 0.5f;
            tblFatherHusbandName.AddCell(cellFatherHusbandName);

            cellFatherHusbandName = new PdfPCell(new Phrase("  Father's / Husband Name :", TableFontmini_ARBold8Nor));
            cellFatherHusbandName.HorizontalAlignment = 0;
            cellFatherHusbandName.PaddingBottom = 5f;
            cellFatherHusbandName.BorderWidth = 0.5f;
            tblFatherHusbandName.AddCell(cellFatherHusbandName);

            cellFatherHusbandName = new PdfPCell(new Phrase(" " + dt.Rows[0]["FatherHusbandName"].ToString(), TableFontmini_ARBold8Nor));
            cellFatherHusbandName.HorizontalAlignment = 0;
            cellFatherHusbandName.PaddingBottom = 5f;
            cellFatherHusbandName.BorderWidth = 0.5f;

            tblFatherHusbandName.AddCell(cellFatherHusbandName);
            doc.Add(tblFatherHusbandName);

            #endregion

            #region RelationShip..!!

            PdfPTable tblRelationShip = new PdfPTable(3);
            float[] colWidthRelationShip = { 100, 500, 700 };
            tblRelationShip.SetWidths(colWidthRelationShip);
            PdfPCell cellRelationShip;


            cellRelationShip = new PdfPCell(new Phrase("4.", TableFontmini_ARBold8Nor));
            cellRelationShip.HorizontalAlignment = 1;

            cellRelationShip.PaddingBottom = 5f;
            cellRelationShip.BorderWidth = 0.5f;
            tblRelationShip.AddCell(cellRelationShip);

            cellRelationShip = new PdfPCell(new Phrase("  Relationship in Respect of (3) above :", TableFontmini_ARBold8Nor));
            cellRelationShip.HorizontalAlignment = 0;
            cellRelationShip.PaddingBottom = 5f;
            cellRelationShip.BorderWidth = 0.5f;
            tblRelationShip.AddCell(cellRelationShip);

            cellRelationShip = new PdfPCell(new Phrase(" " + dt.Rows[0]["RelationShip"].ToString(), TableFontmini_ARBold8Nor));
            cellRelationShip.HorizontalAlignment = 0;
            cellRelationShip.PaddingBottom = 5f;
            cellRelationShip.BorderWidth = 0.5f;

            tblRelationShip.AddCell(cellRelationShip);
            doc.Add(tblRelationShip);

            #endregion

            #region RelationShip..!!

            PdfPTable tblGender = new PdfPTable(3);
            float[] colWidthGender = { 100, 500, 700 };
            tblGender.SetWidths(colWidthGender);
            PdfPCell cellGender;


            cellGender = new PdfPCell(new Phrase("5.", TableFontmini_ARBold8Nor));
            cellGender.HorizontalAlignment = 1;

            cellGender.PaddingBottom = 5f;
            cellGender.BorderWidth = 0.5f;
            tblGender.AddCell(cellGender);

            cellGender = new PdfPCell(new Phrase("  Gender :", TableFontmini_ARBold8Nor));
            cellGender.HorizontalAlignment = 0;

            cellGender.PaddingBottom = 5f;
            cellGender.BorderWidth = 0.5f;
            tblGender.AddCell(cellGender);

            cellGender = new PdfPCell(new Phrase(" " + dt.Rows[0]["Gender"].ToString(), TableFontmini_ARBold8Nor));
            cellGender.HorizontalAlignment = 0;
            cellGender.PaddingBottom = 5f;
            cellGender.BorderWidth = 0.5f;

            tblGender.AddCell(cellGender);
            doc.Add(tblGender);

            #endregion

            /*HR Signature Add*/
            Paragraph paragraph = new Paragraph();
            string imageURL = Server.MapPath("~/HRD/Billinglatestimages/") + "EPFLogo.png";
            iTextSharp.text.Image jpg1 = iTextSharp.text.Image.GetInstance(imageURL);
            //Resize image depend upon your need
            jpg1.ScaleToFit(85f, 85f);
            //jpg1.SetAbsolutePosition(80, 380);
            jpg1.SetAbsolutePosition(60, 730);
            jpg1.Alignment = Element.ALIGN_LEFT;
            doc.Add(paragraph);
            doc.Add(jpg1);
            /*HR Signature Add*/

            /*Emp Signature Add*/




            //Resize image depend upon your need

            /*HR Signature Add*/

            PdfContentByte content = pdfwrite1.DirectContent;
            Rectangle rectangle = new Rectangle(doc.PageSize);
            rectangle.Left += doc.LeftMargin;
            rectangle.Right -= doc.RightMargin;
            rectangle.Top -= doc.TopMargin;
            rectangle.Bottom += doc.BottomMargin;
            rectangle.BorderWidthLeft = 0.5f;
            rectangle.BorderWidthRight = 0.5f;
            rectangle.BorderWidthTop = 0.5f;
            rectangle.BorderWidthBottom = 0.5f;
            content.SetColorStroke(BaseColor.BLACK);
            content.Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height);
            content.Stroke();


            doc.Close();
        }

        #endregion
    }