tags:

views:

72

answers:

5

Is there any way to generate PDF document from asp.net directly from the page output. My requirement is, when user visits a page on my website, there should be a provision to get the same page / report in PDF format. Using iTextSharp, we need to built layout logic agin to generate PDF. If there are any changes in page output in future, I again need to work on logic to generate PDF. Instead I want to generate PDF directly from the page output just by setting "Response.ContentType" property.

A: 

You can set a button on your page that, if clicked, starts rendering a HTML page to PDF - only that the page you're asking it to render is exactly the page the user has clicked the button on. Once you got the PDF you can just send it in the normal way.

This of course requires a program that can render arbitrary HTML pages to pdf. You might want to check out ABCpdf which has always worked for me like a charm, but it's not free.

Nicolas78
+1  A: 

Directly convert .aspx to .pdf

Leniel Macaferi
A: 

http://princexml.com/

They offer an application that converts html to pdf.

ZippyV
+3  A: 

One strategy I use is to develop reports using SQL Server Reporting Services. SSRS reports support export to PDF out of the box.

If you use SSRS 2008, you can even assign arbitrary HTML to a text box and the reporting engine will interpret it fairly well. This allows you to retrieve a snippet of HTML from any page, and present it in a report that will export to PDF without having to manually generate PDF document elements with iTextSharp.

If you go the SSRS 2008 route, check out this thread: http://forums.asp.net/t/1443965.aspx

I hope this helps.

Happy Coding!

kbrimington
A: 

We use ActivePDF WebGrabber - which is designed to do exactly what you described. http://www.activepdf.com/products/serverproducts/webgrabber/

Kyle B.