Exporting an ASPX's HTML to PDF

  • Thread starter Thread starter Valerian John
  • Start date Start date
V

Valerian John

I am looking for a way to sort of redirect the Page.Response content to a
pdf generator component that would create a pdf file on the fly! I wonder
if there is such a thing in the .net world. I see a java based product that
may do this (from CORDA).

This is really my problem: My asp.net page creates a complex report using
web controls and I would like to be able to overcome browser printing issues
by converting the resulting html to pdf on the fly. I would like to avoid
recreating these reports/pages using a 3rd party pdf component's object
model.

TIA,
John
 
neither itext nor corda support more than the simplest html (1.0), no style
support,etc. if you can live with this, have your page use webclient to call
report apsx page, then convert the html to pdf and write back to the client.

-- bruce (sqlwork.com)
 
Thank you, Elton, Steve and Bruce for your responses/help. (Steve: good
articles on your website)

I did run into the iText and HTMLDOC tools but like Bruce has noted they
only do simple html. I also checked out Aspose.pdf and they have a similar
problem (under development).

The suggestion about WebClient seems plausible. Is this how one can do
this? (cut/paste from MSDN) I guess it would still be plain html without
css because css is really applied by the browser on the client-side?
(Perhaps I must use Aspose.pdf, or similar, and recreate the report using
the pdf object model!)

***********
' Initialize the WebRequest.
Dim myRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
' Return the response.
Dim myResponse As WebResponse = myRequest.GetResponse()
'Set the appropriate ContentType
Response.ContentType = "Application/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acrobat.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteFile(FilePath)
Response.End()
Response.Redirect("acrobat.pdf")
' Close the response to free resources.
myResponse.Close()
***********

TIA,
John

(aside: How is Developersdex able to forward reponses to one's post here?)
 
Back
Top