Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
This is the code that i have used to export html to pdf using vb.net.
the pdf file gets saved in the default path given. But i want to export with Save File As option
so that the end user could save the file in desired location.

CODE:
XML
Str.Clear()
                Str.Append("<table cellspacing=1 cellpadding=0 border=0 width=100% align=center class='tblrpt'>")
                Str.Append("<tr class='bbtdwht'><td align='center' colspan='3'><b>No Record(s) Found  </b></td></tr>")
                Str.Append("</table>")
                Dim StrContent As String
                StrContent = Str.ToString
                Dim doc As New Document(PageSize.LETTER, 80, 50, 30, 65)
                Dim fsNew As New StringReader(StrContent)
                Dim document As New Document(PageSize.A4, 80, 50, 30, 65)
                Using fs As New FileStream(Request.ApplicationPath & "/Print/Pf" & Session("User_id") & ".pdf", FileMode.Create)
                    PdfWriter.GetInstance(document, fs)
                    Using stringReader As New StringReader(StrContent)
                        Dim parsedList = html.simpleparser.HTMLWorker.ParseToList(stringReader, Nothing)
                        document.Open()
                        For Each item As Object In parsedList
                            document.Add(DirectCast(item, IElement))
                        Next
                        document.Close()
                    End Using
                End Using
Posted

1 solution

Try to bind your html codes in rdlc file and reportviewer has its inbuild option to export the results to xls, pdf and doc file formats.

Regards,
Bluesathish
 
Share this answer
 
v2
Comments
Divya RS 3-Oct-13 0:27am    
Thanks for the reply, but i need to do tis in page report
bluesathish 3-Oct-13 1:08am    
Page report!, what do you mean to say?

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