the http reponse to file? ASP.NET 2.0

G

Guest

I want to generate a pdf file of "the current page".

It is a ASP.NET aspx file created partly from GET parameters, but most often
using the ASP.NET event model (i.e. clicking buttons etc).

One of the buttons is called "Generate a pdf document of the current page"
and it clicking it should create a pdf document on the server side and
returning the pdf to the user.

To my aid I have a server side component that can convert a file or the html
content of a URL to a pdf document. So if I somehow can generate the
information of the current aspx page to file, I can convert it to pdf and
change the Response.ContentType to "application/pdf".

But the question is how to generate the file that I want to convert. If I
send the current URL to the pdf component, it will point to the page and how
it looks when no interaction has been done. What I really want is the page
after all clicks, i.e. how it looks "right now".

Any ideas? Thank you,
 
J

Joerg Jooss

Thus wrote Fredrik,
I want to generate a pdf file of "the current page".

It is a ASP.NET aspx file created partly from GET parameters, but most
often using the ASP.NET event model (i.e. clicking buttons etc).

One of the buttons is called "Generate a pdf document of the current
page" and it clicking it should create a pdf document on the server
side and returning the pdf to the user.

To my aid I have a server side component that can convert a file or
the html content of a URL to a pdf document. So if I somehow can
generate the information of the current aspx page to file, I can
convert it to pdf and change the Response.ContentType to
"application/pdf".

But the question is how to generate the file that I want to convert.
If I send the current URL to the pdf component, it will point to the
page and how it looks when no interaction has been done. What I really
want is the page after all clicks, i.e. how it looks "right now".

Any ideas? Thank you,

HttpResponse allows you set another stream as a filter using HttpResponse.Filter.
You could use that to write the response to a temporary file, create the
PDF, and write the PDF back to the actual response stream.

Cheers,
 
G

Guest

Very interesting!

It seems the file isn't created until the Response ends. This seems natural
to me when thinking about it.

But when the response has ended, I per definition have lost my chance to
alter the response (remeber, I wamt to send the pdf instead). I guess I will
have to trigger another request somehow, and in the new Response show the pdf.

Havn't still figured out the last details yet. Thanks, anyhow, for your kind
help.

Regards
 
J

Joerg Jooss

Thus wrote Fredrik,
Very interesting!

It seems the file isn't created until the Response ends. This seems
natural to me when thinking about it.

Are you sure you just don't need a Response.Flush()?

Cheers,
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top