Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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


This code creates PDF document but creates all columns with same with.
I want Column with same as html document.

Thanks in Advance
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900