export a page in PDF format RRS feed

  • Question

  • User-1338060929 posted



    How to export asp.net page to pdf format in vb.net


    Saturday, June 15, 2013 2:56 AM


  • 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! Laughing

    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)
    			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.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 20, 2013 4:05 AM

All replies