private void Generatepdf(string cnscid) { try { string tokenno = ""; string docname = ""; string room = ""; SqlDataReader dr = objcon.GetReader("select IN028_01_01.IN028_70,IN013_02,IN028_03,IN013_25 FROM IN028_01_01 INNER JOIN IN028 ON IN028.IN028_01=IN028_01_01.IN028_01 INNER JOIN IN013 ON IN013.IN013_01=IN028.IN013_01 where IN028.IN028_01='" + cnscid + "'"); if (objcon.dr.Read()) { tokenno = objcon.dr.GetString(0); docname = objcon.dr.GetString(1); //lbl_datetime.Text = objcon.dr.GetDateTime(2).ToString("dd-MMM-yyyy hh:mm tt"); room = objcon.dr.GetString(3); } objcon.dr.Close(); string Fortunelogo = Server.MapPath("..//Images//printlogo.png"); string pdfheader = Server.MapPath("..//Images//printname.png"); var document = new Document(PageSize.A4, 50, 30, 20, 20); var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); document.Open(); var titleFont = FontFactory.GetFont("Tahoma", 24, Font.BOLDITALIC, new Color(125, 88, 15)); var itemsTable = @"<table border=0 cellpadding=3 cellspacing=3 >"; itemsTable += string.Format("<font style=\"font-family:Tahoma;border-collapse:separate;border-spacing: 0 1em;\">"); itemsTable += string.Format("<tr><td align=\"center\" style=\"color:#000000;\"><table border=\"0\"><tr><td align=\"Left\" colspan=\"2\"><img src='" + Fortunelogo + "' height=\"5px\" width=\"5px\" style=border-style: none></td></tr><tr><td colspan=\"20\" align=\"left\" style=\"color:#000000;margin:100px;\" font-size=\"24px\" Valign=\"middle\">"Left\"" colspan="\"20\""> Date :" + DateTime.Now.ToString("dd/MMM/yyyy") + " </td></tr><tr><td align=\"Left\" colspan=\"20\" style=\"color:#000000;border:solid;\" >Token No: ^__b style=""color: #000000; border: solid; font-size: xx-large">" + tokenno + "</td></tr><tr><td align=\"Left\" colspan=\"20\" style=\"color:#000000;border:solid;\" >Room No : ^__b style=""color: #000000; border: solid; font-size: xx-large">" + room + "</td></tr><tr><td align=\"Left\" colspan=\"20\" style=\"color:#000000;border:solid;\" >Please be seated .You will be served shortly.</td></tr>"); itemsTable += string.Format("</table></td></tr></font></table>"); ArrayList htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(itemsTable), null); for (int k = 0; k < htmlarraylist.Count; k++) { document.Add((IElement)htmlarraylist[k]); } document.Close(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=token.pdf")); Response.BinaryWrite(output.ToArray()); } catch (Exception exp) { Alert.Show(exp.Message.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)