Exporting an ASPX's HTML to PDF

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
 
B

Bruce Barker

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

Valerian John

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top