private void logo()
 {
     // logo showing code
     byte[] logo = othersGateway.loadLogo();
     if (logo != null)
     {
         MemoryStream memoryStream = new MemoryStream(logo);
         logoBox.Image = Image.FromStream(memoryStream);
     }
     else
     {
         logoBox.Image   = null;
         logoBox.Visible = false;
     }
 }
        public void MakePdf()
        {
            string str1 = DateTime.Today.ToString("u");
            string str2 = str1.Replace(':', 's');
            string str3 = str2.Replace(',', 'd');
            //    string filname = DateTime.Today.ToString("");
            string        fileNamePrifix = customerNameBox.Text.Trim();
            string        final_fileName = fileNamePrifix + str3;
            string        dirctory       = Path.GetDirectoryName(@"C:\Users\Public\");
            DirectoryInfo df             = new DirectoryInfo(dirctory + @"\voucher\");

            if (df.Exists == false)
            {
                Directory.CreateDirectory(dirctory + @"\voucher\");
            }
            string filePath = df + final_fileName;


            Document  document = new Document(PageSize.A4, 75, 75, 75, 75);
            PdfWriter create   = PdfWriter.GetInstance(document, new FileStream(filePath + ".pdf", FileMode.Create));

            document.Open();

            // Font Entry
            BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font hedingfont = new iTextSharp.text.Font(bf, 30, iTextSharp.text.Font.BOLD, BaseColor.BLUE);
            iTextSharp.text.Font smfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            iTextSharp.text.Font thfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            iTextSharp.text.Font tdfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            iTextSharp.text.Font signfont   = new iTextSharp.text.Font(bf, 11, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            signfont.SetColor(23, 45, 12);



            byte[] image = introduce.loadLogo();
            if (image != null)
            {
                Image logo = Image.GetInstance(image);
                logo.SetAbsolutePosition(40, 700);
                logo.ScaleAbsoluteWidth(70);
                logo.ScaleAbsoluteHeight(70);
                document.Add(logo);
            }



            // Customer Data
            Paragraph Header = new Paragraph();

            Header.Alignment = Element.ALIGN_CENTER;


            IntroduceModel introduction = introduce.GetInformation();

            if (introduction != null)
            {
                string instituteBox = introduction.InstituteName;
                string emailBox     = introduction.Email;
                string addresss     = introduction.Address;
                string web          = introduction.WebSite;
                string mobiles      = introduction.Mobile;
                string ownerName    = introduction.OwnerName;

                Header.Add(new Chunk(instituteBox, hedingfont));
                Header.Add(new Chunk("\n" + addresss, smfont));
                Header.Add(new Chunk("\nCell :" + mobiles + ", \n " + web + " , " + emailBox, smfont));
                document.Add(Header);
            }
            else
            {
                Header.Add(new Chunk("It is Your Institute Name", hedingfont));
                Header.Add(new Chunk("\nSomething Address text will visible here", smfont));
                Header.Add(new Chunk("\nCell : -9087948059830, \n Web: N/A, Email: N/A ", smfont));
                document.Add(Header);
            }

            DottedLineSeparator separator = new DottedLineSeparator();

            separator.LineWidth = 1f;
            Chunk linebreak = new Chunk(separator);

            document.Add(linebreak);


            string    customerName = customerNameBox.Text.Trim();
            string    address      = addressTextBox.Text.Trim();
            string    mobile       = mnumberBox.Text.Trim();
            Paragraph csdata       = new Paragraph();

            csdata.Alignment = Element.ALIGN_LEFT;
            csdata.Add(new Chunk("Customer Name : " + customerName + "\nAddress : " + address + "\nMabile Number : " + mobile + "\n Date : " + DateTime.Now.ToString("dd/MM/yyyy"), smfont));
            document.Add(csdata);
            DottedLineSeparator separator2 = new DottedLineSeparator();

            separator2.LineWidth = 1f;
            Chunk linebreak2 = new Chunk(separator2);

            document.Add(linebreak2);



            //Write the table
            float[]   columnWidths = { 1.5f, 7f, 2.2f, 4f };
            PdfPTable ItemsRecord  = new PdfPTable(columnWidths);

            ItemsRecord.DefaultCell.Column.Alignment = Element.ALIGN_CENTER;
            ItemsRecord.WidthPercentage           = 100;
            ItemsRecord.DefaultCell.PaddingBottom = 4f;
            ItemsRecord.AddCell(new Phrase("Sl", thfont));
            ItemsRecord.AddCell(new Phrase("Product  Description", thfont));
            ItemsRecord.AddCell(new Phrase("Quantity", thfont));
            ItemsRecord.AddCell(new Phrase("Net Price", thfont));
            //table Data
            var totalQuantity = listofStockOut.Sum(x => x.Quantity);
            var totalamount   = listofStockOut.Sum(x => x.Price).ToString(CultureInfo.CreateSpecificCulture("bn-BD"));
            int ci            = 0;
            int lc            = listofStockOut.Count;

            foreach (var items in listofStockOut)
            {
                if (ci <= lc)
                {
                    ci++;
                }
                ItemsRecord.AddCell(new Phrase(ci.ToString(), tdfont));
                ItemsRecord.AddCell(new Phrase(items.CatagoryName + " : " + items.ItemName + " Sl/Mo:" + items.Model, tdfont));
                ItemsRecord.AddCell(new Phrase(items.Quantity.ToString(), tdfont));
                ItemsRecord.AddCell(new Phrase(items.Price.ToString(), tdfont));
            }
            PdfPCell cell = new PdfPCell(new Phrase("Total :  ", tdfont));

            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            cell.Colspan             = 2;
            ItemsRecord.AddCell(cell);
            ItemsRecord.AddCell(new Phrase(totalQuantity.ToString(), tdfont));
            ItemsRecord.AddCell(new Phrase(totalamount, tdfont));
            document.Add(ItemsRecord);
            document.Add(new Chunk("\n\n\n"));



            //Author
            Paragraph prgAuthor = new Paragraph();

            prgAuthor.Alignment       = Element.ALIGN_CENTER;
            prgAuthor.IndentationLeft = 250f;
            prgAuthor.Add(new Chunk("Received by", signfont));
            prgAuthor.Add(new Chunk("\n" + DateTime.Now.ToString("dd/MM/yyyy"), signfont));
            document.Add(prgAuthor);
            document.Add(new Chunk("\n\n\n"));
            DottedLineSeparator separator4 = new DottedLineSeparator();

            separator4.LineWidth = 1f;
            Chunk linebreak4 = new Chunk(separator4);

            document.Add(linebreak4);

            document.Add(new Chunk("\nN:B: \n"));

            DottedLineSeparator separator5 = new DottedLineSeparator();

            separator5.LineWidth = 1f;
            Chunk linebreak5 = new Chunk(separator5);

            document.Add(linebreak5);

            document.Add(new Chunk("\n"));
            document.Close();
            create.Close();
            System.Diagnostics.Process.Start(filePath + ".pdf");
        }