Dim fileName As String = Session("ClientGenCode") & "Leather_Pdf_" + DateTime.Now.ToShortDateString()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName + ".pdf"))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim html As String = ViewState("htmlText").ToString()
Dim sb = New System.Text.StringBuilder()
sb.Append(html)
Dim objSW = New StringWriter(sb)
Dim objTW = New HtmlTextWriter(objSW)
Dim objSR As New StringReader(objSW.ToString())
Dim objPDF = New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F)
Dim objHW = New HTMLWorker(objPDF)
PdfWriter.GetInstance(objPDF, Response.OutputStream)
objPDF.Open()
objHW.Parse(objSR)
objPDF.Close()
Response.Write(objPDF)
Response.End()