Public Sub ToPdf(ByVal fileName As String, ByVal html As String) Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName + ".pdf")) Response.Cache.SetCacheability(HttpCacheability.NoCache) 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() End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)