Easiest aspx to pdf?


What is the easiest way to convert the HTML output (looks like a simple
report, but many procedures and placeholders in code behind) of an
already existing aspx page into a PDF? BindHTML or
BindHTMLFromURL doesn’t work. So whats the alternative other than
re-creating the entire page with Aspose.pdf objects scattered across
the page? Thanks.


Please refer to http://www.aspose.com/Community/Blogs/tommy.wang/archive/2006/01/01/38656.aspx. There is an example about how to convert aspx into PDF. Currently only simple HTML is supported. We are now working to support more HTML tags and css.


Originally, after reading older posts, I was under the impression that I couldn't use BindHTML to convert aspx to PDF, but tried anyways and got this error:

Unknown sub element in Row element. The element name is Row.

Now I tried the solution based on the link you gave me and the error message is back. What is this error refering to? Does this have to do with the restriction to simple HTML? If I have CSS classes involved, will it give me an error or will it just ignore it?

Also, my solution (below) was placed at the end of the Page_Load function of the page that I want to convert. Is this right? Is it really that simple? I hope so... I have many more pages to apply this to.

If CStr(Me.Request.QueryString("mode")) = "pdf" Then

Dim pdf As Pdf

Dim strURL As String

Dim postStream As System.IO.MemoryStream

Dim myDataBuffer As Byte()

Dim mappath As String

Dim webClient As System.Net.WebClient

pdf = New Aspose.Pdf.Pdf

strURL = Me.Request.Url.ToString()

webClient = New System.Net.WebClient

myDataBuffer = webClient.DownloadData(strURL)

postStream = New System.IO.MemoryStream(myDataBuffer)


mappath = "c:/temp/testpdf.pdf"

pdf.Save(mappath, SaveType.OpenInBrowser, Response)

End If


Can you show us the codes of the page that you want to convert.

Now BindHTML only support the simple HTML tags, it will ignore the CSS classes involved.

If we have your codes and get the same error, it will be easy for us to find the answer.