void tmrPdfInterval_Tick(object sender, System.Timers.ElapsedEventArgs e)
{
System.Guid guid = System.Guid.NewGuid();
String PdfId = guid.ToString();
SqlDataAdapter adptr = new SqlDataAdapter("select firstname,middlename,lastname,email from userdetails", con);
DataSet ds = new DataSet();
adptr.Fill(ds, "userdetails");
iTextSharp.text.Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
//iTextSharp.text.pdf.PdfWriter wri = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(@"D:\Service\Pdf\" + PdfId + ".pdf", FileMode.OpenOrCreate));
iTextSharp.text.pdf.PdfWriter wri = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(@"D:\Service\Pdf\StartPdf.pdf", FileMode.OpenOrCreate));
doc.AddAuthor("Rahul");
doc.AddSubject("Rahul Test Windows Service pdf generator");
doc.AddTitle("This a testing by Rahul");
doc.Open();
iTextSharp.text.Cell lineBreak = new iTextSharp.text.Cell("\n");
lineBreak.Colspan = 8;
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(@"D:\Service\SampleWindowsService\SampleWindowsService\Images\redcolor.GIF");
img.ScalePercent(135, 15);
iTextSharp.text.Cell lineImage = new iTextSharp.text.Cell(img);
lineImage.Colspan = 8;
iTextSharp.text.Cell ContentCell;
iTextSharp.text.Table personalTable;
personalTable = new iTextSharp.text.Table(8);
personalTable.BorderColor = iTextSharp.text.Color.WHITE;
personalTable.BackgroundColor = iTextSharp.text.Color.PINK;
personalTable.DefaultCellBorderColor = iTextSharp.text.Color.WHITE;
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("THIS IS A WINDOWS SERVICE TEST FOR IIE TEAM 123", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 12)));
ContentCell.Colspan = 8;
ContentCell.SetHorizontalAlignment("center");
Cell cell1 = new Cell();
cell1.BorderColor = Color.PINK;
cell1.BackgroundColor = Color.PINK;
cell1.Add(new Paragraph("*************************************************", FontFactory.GetFont(FontFactory.HELVETICA, 10u)));
cell1.Colspan = 8;
cell1.SetHorizontalAlignment("center");
personalTable.AddCell(ContentCell);
personalTable.AddCell(cell1);
doc.Add(personalTable);
personalTable = new iTextSharp.text.Table(8);
personalTable.BorderColor = iTextSharp.text.Color.WHITE;
personalTable.DefaultCellBorderColor = iTextSharp.text.Color.WHITE;
personalTable.AddCell(lineBreak);
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("Applicant Data", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 11)));
ContentCell.Colspan = 8;
ContentCell.SetHorizontalAlignment("left");
personalTable.AddCell(ContentCell);
personalTable.AddCell(lineBreak);
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("Personal Information", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLDITALIC, 11)));
ContentCell.Colspan = 8;
ContentCell.SetHorizontalAlignment("left");
personalTable.AddCell(ContentCell);
doc.Add(personalTable);
personalTable = new iTextSharp.text.Table(8);
personalTable.BorderColor = iTextSharp.text.Color.WHITE;
personalTable.DefaultCellBorderColor = iTextSharp.text.Color.WHITE;
personalTable.AddCell(lineBreak);
personalTable.AddCell(lineImage);
doc.Add(personalTable);
personalTable = new iTextSharp.text.Table(8);
personalTable.BorderColor = iTextSharp.text.Color.WHITE;
personalTable.DefaultCellBorderColor = iTextSharp.text.Color.WHITE;
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("First Name", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 11)));
ContentCell.Colspan = 2;
ContentCell.SetHorizontalAlignment("left");
personalTable.AddCell(ContentCell);
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("Middle Initial", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 11)));
ContentCell.Colspan = 2;
ContentCell.SetHorizontalAlignment("left");
personalTable.AddCell(ContentCell);
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("Last Name", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 11)));
ContentCell.Colspan = 2;
ContentCell.SetHorizontalAlignment("left");
personalTable.AddCell(ContentCell);
ContentCell = new iTextSharp.text.Cell();
ContentCell.Add(new iTextSharp.text.Paragraph("Email Address", iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.TIMES_BOLD, 11)));
ContentCell.Colspan = 2;
ContentCell.SetHorizontalAlignment("center");
personalTable.AddCell(ContentCell);
doc.Add(personalTable);
doc.Close();
}