private void ExecuteGenerateCertificate()
        {
            if (!ValidateFields())
            {
                MessageBox.Show("Please Enter all the required fields, then generate certificate");
                return;
            }
            CertificatePath = String.Empty;
            Thread.Sleep(400);
            string     certificateName = "Certificate.pdf";
            Document   document        = new Document();
            FileStream fs     = new FileStream(certificateName, FileMode.Create, FileAccess.Write);
            PdfWriter  writer = PdfWriter.GetInstance(document, fs);

            document.Open();

            PdfContentByte pdfContentByte = writer.DirectContent;
            int            textDown       = -50;

            if (CurrentMarriage.GroomPhoto == null && CurrentMarriage.BridePhoto == null)
            {
                textDown = 50;
            }

            Paragraph title = new Paragraph();

            title.Alignment = Element.ALIGN_CENTER;
            title.Font      = FontFactory.GetFont(FontFactory.TIMES_BOLD, 18f, Font.UNDERLINE, BaseColor.BLACK);
            title.Add("MARRIAGE CERTIFICATE");
            ColumnText ct = new ColumnText(pdfContentByte);

            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(30, 520 - textDown, 560, 30));
            ct.AddElement(title);
            ct.Go();

            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            int column1LeftMargin = 120;
            int column2LeftMargin = 260;

            if (CurrentMarriage.GroomPhoto != null && CurrentMarriage.BridePhoto != null)
            {
                Image i = Image.GetInstance(CurrentMarriage.GroomPhoto);
                i.Alignment = Image.LEFT_ALIGN;
                i.ScaleToFit(94f, 144f);
                i.SetAbsolutePosition(200, 420);
                pdfContentByte.AddImage(i);
                i           = Image.GetInstance(CurrentMarriage.BridePhoto);
                i.Alignment = Image.LEFT_ALIGN;
                i.ScaleToFit(94f, 144f);
                i.SetAbsolutePosition(310, 420);
                pdfContentByte.AddImage(i);
            }

            //GroomName = "Rashid MV";
            //GroomFatherName = "Khader KM";
            //GroomHouseName = "Rashid Manzil";
            //GroomArea = "Kottakunnummal";
            //GroomPincode = "673521";
            //GroomPostOffice = "Iringal";
            //GroomDistrict = "Kozhikkode";
            //GroomState = "Kerala";
            //GroomCountry = "India";

            //BrideName = "Hiba Fahisa AV";
            //BrideFatherName = "Asharaf AV";
            //BrideHouseName = "Kulangarath Kuniyil";
            //BrideArea = "Arakkilad";
            //BridePincode = "675302";
            //BridePostOffice = "Nadakkuthazhe";
            //BrideDistrict = "Kozhikkode";
            //BrideState = "Kerala";
            //BrideCountry = "India";
            //MarriagePlace = "Moorad";


            Paragraph registation = new Paragraph("Reg.No : " + RegNo);

            registation.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 11f, BaseColor.BLACK);
            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(column1LeftMargin, 436, 416, 30));
            ct.AddElement(registation);
            ct.Go();

            Paragraph groomDetailsLabels = new Paragraph("Name of Bridegroom   :\n" +
                                                         "Date of Birth                :\n" +
                                                         "Name of Father           :\n" +
                                                         "Permenant Address    :");

            groomDetailsLabels.Leading = 12;
            groomDetailsLabels.Font    = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);
            ct.SetSimpleColumn(new Rectangle(column1LeftMargin, 416, 416, 30));
            ct.AddElement(groomDetailsLabels);
            ct.Go();
            Chunk groomName = new Chunk(GroomName);

            groomName.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK);
            Paragraph groomDetails = new Paragraph();

            groomDetails.Font = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);
            groomDetails.Add(groomName);

            String details = "\n" + GroomDOB.ToShortDateString() + "\n" + GroomFatherName + "\n"
                             + GroomHouseName + " [House],\n" + GroomArea + ", " + GroomPostOffice + ",\n"
                             + GroomDistrict + ", " + GroomState + ",\n" + GroomCountry + " - " + GroomPincode;

            groomDetails.Add(details);
            groomDetails.Leading = 12;
            ct.SetSimpleColumn(new Rectangle(column2LeftMargin, 416, 416, 30));
            ct.AddElement(groomDetails);
            ct.Go();

            Paragraph brideDetailsLabels = new Paragraph("Name of Bride             :\n" +
                                                         "Date of Birth                :\n" +
                                                         "Name of Father           :\n" +
                                                         "Permenant Address    :");

            brideDetailsLabels.Leading = 12;
            brideDetailsLabels.Font    = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);
            ct.SetSimpleColumn(new Rectangle(column1LeftMargin, 326, 416, 30));
            ct.AddElement(brideDetailsLabels);
            ct.Go();
            Chunk brideName = new Chunk(BrideName);

            brideName.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK);
            Paragraph brideDetails = new Paragraph();

            brideDetails.Font = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);
            brideDetails.Add(brideName);

            details = "\n" + BrideDOB.ToShortDateString() + "\n" + BrideFatherName + "\n"
                      + BrideHouseName + " [House],\n" + BrideArea + ", " + BridePostOffice + ",\n"
                      + BrideDistrict + ", " + BrideState + ",\n" + BrideCountry + " - " + BridePincode;
            brideDetails.Add(details);
            brideDetails.Leading = 12;
            ct.SetSimpleColumn(new Rectangle(column2LeftMargin, 326, 416, 30));
            ct.AddElement(brideDetails);
            ct.Go();


            Paragraph placeDateLabels = new Paragraph("Place of Marriage        :\n" +
                                                      "Date of Marriage         :\n");

            placeDateLabels.Leading = 12;
            placeDateLabels.Font    = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);
            ct.SetSimpleColumn(new Rectangle(column1LeftMargin, 230, 416, 30));
            ct.AddElement(placeDateLabels);
            ct.Go();
            Paragraph placeDateDetails = new Paragraph();

            placeDateDetails.Font = FontFactory.GetFont(FontFactory.HELVETICA, 11f, BaseColor.BLACK);

            details = MarriagePlace + "\n" + MarriageDate.ToShortDateString();
            placeDateDetails.Add(details);
            placeDateDetails.Leading = 12;
            ct.SetSimpleColumn(new Rectangle(column2LeftMargin, 230, 416, 30));
            ct.AddElement(placeDateDetails);
            ct.Go();


            //pdfContentByte.SetColorFill(BaseColor.BLACK);
            //pdfContentByte.SetFontAndSize(bf, 12);

            Chunk masjidName = new Chunk("'" + MasjidName + "'");

            masjidName.Font = FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK);

            Paragraph content = new Paragraph();

            content.SpacingBefore = 10;
            content.SpacingAfter  = 10;
            content.Font          = FontFactory.GetFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK);
            string contentText1 = "             Certify that the Marriage between the above mentioned persons was solemnised by Mahallu Khazi of ";
            string contentText2 = " in the presence of their friends and relatives according to the Islamic Shareeath Law.";

            content.Add(contentText1);
            content.Add(masjidName);
            content.Add(contentText2);
            content.Alignment = Element.ALIGN_JUSTIFIED;
            ct.SetSimpleColumn(new Rectangle(30, 210, 540, 50));
            ct.AddElement(content);
            ct.Go();

            Paragraph secretary = new Paragraph("SECRETARY");

            secretary.Alignment = Element.ALIGN_RIGHT;
            secretary.Font      = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(30, 150, 540, 30));
            ct.AddElement(secretary);
            ct.Go();

            Paragraph place = new Paragraph("Place : " + Place + "\nDate  : " + DateTime.Now.ToShortDateString());

            place.Alignment = Element.ALIGN_LEFT;
            place.Font      = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(40, 150, 540, 30));
            ct.AddElement(place);
            ct.Go();

            document.Close();
            fs.Close();
            writer.Close();

            String currentFolder = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

            CertificatePath = Path.Combine(currentFolder, "Certificate.pdf");
        }
        private void ExecuteGenerateCertificate1()
        {
            CertificatePath = String.Empty;
            Thread.Sleep(400);
            string     certificateName = "Certificate.pdf";
            Document   document        = new Document();
            FileStream fs     = new FileStream(certificateName, FileMode.Create, FileAccess.Write);
            PdfWriter  writer = PdfWriter.GetInstance(document, fs);

            document.Open();

            PdfContentByte pdfContentByte = writer.DirectContent;
            int            textDown       = 0;

            if (String.IsNullOrEmpty(GroomPhotoPath) && String.IsNullOrEmpty(GroomPhotoPath))
            {
                textDown = 70;
            }

            Paragraph title = new Paragraph();

            title.Alignment = Element.ALIGN_CENTER;
            title.Font      = FontFactory.GetFont(FontFactory.TIMES_BOLD, 18f, Font.UNDERLINE, BaseColor.BLACK);
            title.Add("MARRIAGE CERTIFICATE");
            ColumnText ct = new ColumnText(pdfContentByte);

            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(30, 520 - textDown, 560, 30));
            ct.AddElement(title);
            ct.Go();

            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            int column1LeftMargin = 120;
            int column2LeftMargin = 370;

            if (CurrentMarriage.GroomPhoto != null && CurrentMarriage.BridePhoto != null)
            {
                Image i = Image.GetInstance(CurrentMarriage.GroomPhoto);
                i.Alignment = Image.LEFT_ALIGN;
                i.ScaleToFit(94f, 144f);
                i.SetAbsolutePosition(200, 360);
                pdfContentByte.AddImage(i);
                i           = Image.GetInstance(CurrentMarriage.BridePhoto);
                i.Alignment = Image.LEFT_ALIGN;
                i.ScaleToFit(94f, 144f);
                i.SetAbsolutePosition(310, 360);
                pdfContentByte.AddImage(i);
            }

            GroomName       = "Rashid MV";
            GroomFatherName = "Khader KM";
            GroomHouseName  = "Rashid Manzil";
            GroomArea       = "Kottakunnummal";
            GroomPincode    = "673521";
            GroomPostOffice = "Iringal";
            GroomDistrict   = "Kozhikkode";
            GroomState      = "Kerala";
            GroomCountry    = "India";

            BrideName       = "Hiba Fahisa AV";
            BrideFatherName = "Asharaf AV";
            BrideHouseName  = "Kulangarath Kuniyil";
            BrideArea       = "Arakkilad";
            BridePincode    = "675302";
            BridePostOffice = "Nadakkuthazhe";
            BrideDistrict   = "Kozhikkode";
            BrideState      = "Kerala";
            BrideCountry    = "India";
            MarriagePlace   = "Moorad";

            Paragraph groomName = new Paragraph(GroomName);

            groomName.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct             = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(column1LeftMargin, 356, 540, 30));
            ct.AddElement(groomName);
            ct.Go();
            Paragraph brideName = new Paragraph(BrideName);

            brideName.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct             = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(column2LeftMargin, 356, 540, 30));
            ct.AddElement(brideName);
            ct.Go();

            pdfContentByte.SetColorFill(BaseColor.DARK_GRAY);
            pdfContentByte.SetFontAndSize(bf, 12);

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, "S/o. " + GroomFatherName, column1LeftMargin, 324, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, "D/o. " + BrideFatherName, column2LeftMargin, 324, 0);
            pdfContentByte.EndText();


            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, "Date of Birth: " + GroomDOB.ToShortDateString(), column1LeftMargin, 308, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, "Date of Birth: " + BrideDOB.ToShortDateString(), column2LeftMargin, 308, 0);
            pdfContentByte.EndText();

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, GroomHouseName + " [House],", column1LeftMargin, 292, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, BrideHouseName + " [House],", column2LeftMargin, 292, 0);
            pdfContentByte.EndText();

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, GroomArea + ",", column1LeftMargin, 276, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, BrideArea + ",", column2LeftMargin, 276, 0);
            pdfContentByte.EndText();

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, GroomPostOffice + " [Post],", column1LeftMargin, 260, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, BridePostOffice + " [Post],", column2LeftMargin, 260, 0);
            pdfContentByte.EndText();

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, GroomDistrict + " - " + GroomPincode + ",", column1LeftMargin, 244, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, BrideDistrict + " - " + BridePincode + ",", column2LeftMargin, 244, 0);
            pdfContentByte.EndText();

            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, GroomState + ", " + GroomCountry, column1LeftMargin, 228, 0);
            pdfContentByte.EndText();
            pdfContentByte.BeginText();
            pdfContentByte.ShowTextAligned(0, BrideState + ", " + BrideCountry, column2LeftMargin, 228, 0);
            pdfContentByte.EndText();

            Chunk dateOfMarriage = new Chunk("'" + MarriageDate.ToShortDateString() + "'");

            dateOfMarriage.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            Chunk placeOfMarriage = new Chunk("'" + MarriagePlace + "'");

            placeOfMarriage.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            Chunk masjidName = new Chunk("'" + MasjidName + "'");

            masjidName.Font = FontFactory.GetFont(FontFactory.HELVETICA_BOLDOBLIQUE, 12f, BaseColor.BLACK);

            Paragraph content = new Paragraph();

            content.SpacingBefore = 10;
            content.SpacingAfter  = 10;
            content.Font          = FontFactory.GetFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK);
            string contentText1 = "             Certify that the Marriage between the above mentioned persons was solemnised by Mahallu Khazi of ";
            string contentText2 = " in the presence of their friends and relatives on ";
            string contentText3 = " at ";
            string contentText4 = " according to the Islamic Shareeath Law.";

            content.Add(contentText1);
            content.Add(masjidName);
            content.Add(contentText2);
            content.Add(dateOfMarriage);
            content.Add(contentText3);
            content.Add(placeOfMarriage);
            content.Add(contentText4);
            content.Alignment = Element.ALIGN_JUSTIFIED;
            ct.SetSimpleColumn(new Rectangle(30, 200, 560, 50));
            ct.AddElement(content);
            ct.Go();

            Paragraph secretary = new Paragraph("SECRETARY");

            secretary.Alignment = Element.ALIGN_RIGHT;
            secretary.Font      = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(30, 120, 540, 30));
            ct.AddElement(secretary);
            ct.Go();

            Paragraph place = new Paragraph("Place : " + Place + "\nDate  : " + DateTime.Now.ToShortDateString());

            place.Alignment = Element.ALIGN_LEFT;
            place.Font      = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12f, BaseColor.BLACK);
            ct = new ColumnText(writer.DirectContent);
            ct.SetSimpleColumn(new Rectangle(40, 120, 540, 30));
            ct.AddElement(place);
            ct.Go();

            document.Close();
            fs.Close();
            writer.Close();

            String currentFolder = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

            CertificatePath = Path.Combine(currentFolder, "Certificate.pdf");
        }