private void ExportGridToPDF() { username = (string)(Session["username"]); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + username + "'s Purchase.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); //gv_CartProduct.DataBind(); gv_CartProduct.RenderControl(hw); //gv_CartProduct.HeaderRow.Style.Add("width", "15%"); //gv_CartProduct.HeaderRow.Style.Add("font-size", "10px"); //gv_CartProduct.Style.Add("text-decoration", "none"); //gv_CartProduct.Style.Add("font-family", "Arial, Helvetica, sans-serif;"); //gv_CartProduct.Style.Add("font-size", "8px"); StringReader sr = new StringReader(sw.ToString()); string str = "<h1 title=’Header’ align=’Center’> Thank You " + username + ", for shopping at ShopNow</h1><br><table align=’Center’><tr><td style=’width:100px;color:green’> You have made successful payment at ShopNow online shop. Please keep this invoice. Thank You</td></tr></table>"; StringReader sr1 = new StringReader(str); Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr1); htmlparser.Parse(sr); ConfirmPurchase(); pdfDoc.Close(); Response.Write(pdfDoc); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)