Answered by:
export a page in PDF format

Question
-
User-1338060929 posted
Hi
How to export asp.net page to pdf format in vb.net
Saturday, June 15, 2013 2:56 AM
Answers
-
User-46749029 posted
Wow! It seems that the need regarding converting aspx page to other file formats is hot now. I am testing with Spire.Doc for .NET component the conversion at present. I have done it. Share my code with other guys here. Good luck!
Dim document As New Document() Using buffer As New MemoryStream() Using writer As TextWriter = New StreamWriter(buffer, Encoding.UTF8) Using htmlWriter As New HtmlTextWriter(writer) Me.RenderControl(htmlWriter) htmlWriter.Flush() writer.Flush() buffer.Position = 0 Using reader As StreamReader = New System.IO.StreamReader(buffer, Encoding.UTF8) Dim baseHref As String = Request.Url.AbsoluteUri document.LoadHTML(reader, baseHref, Spire.Doc.Documents.XHTMLValidationType.None) document.SaveToFile("Sample.pdf", FileFormat.PDF, Response,HttpContentType.Attachment) End Using End Using End Using End Using
When you have a need to convert aspx page to Word(doc, docx), you could refer some solutions from other post as below.
http://forums.asp.net/p/1776279/5428150.aspx/1?Re+convert+aspx+page+to+word+document
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, June 20, 2013 4:05 AM
All replies
-
User-1618234021 posted
There are several ways to do that. See the following:
http://www.codeproject.com/Articles/200079/All-in-One-Export-Data-in-ASP-NET
Saturday, June 15, 2013 4:08 AM -
User1607087669 posted
hello
anand
just go this link
you will find ouy answer
http://www.aspsnippets.com/DownloadFile.aspx?File=206bafaf-9a79-4797-9a40-92cce9bd002f.zip
thanks
manish
Monday, June 17, 2013 12:48 PM -
User-46749029 posted
Wow! It seems that the need regarding converting aspx page to other file formats is hot now. I am testing with Spire.Doc for .NET component the conversion at present. I have done it. Share my code with other guys here. Good luck!
Dim document As New Document() Using buffer As New MemoryStream() Using writer As TextWriter = New StreamWriter(buffer, Encoding.UTF8) Using htmlWriter As New HtmlTextWriter(writer) Me.RenderControl(htmlWriter) htmlWriter.Flush() writer.Flush() buffer.Position = 0 Using reader As StreamReader = New System.IO.StreamReader(buffer, Encoding.UTF8) Dim baseHref As String = Request.Url.AbsoluteUri document.LoadHTML(reader, baseHref, Spire.Doc.Documents.XHTMLValidationType.None) document.SaveToFile("Sample.pdf", FileFormat.PDF, Response,HttpContentType.Attachment) End Using End Using End Using End Using
When you have a need to convert aspx page to Word(doc, docx), you could refer some solutions from other post as below.
http://forums.asp.net/p/1776279/5428150.aspx/1?Re+convert+aspx+page+to+word+document
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, June 20, 2013 4:05 AM -
User-37316421 posted
Thanks a lot Manish
Friday, December 13, 2013 3:20 AM