you need to use something like MigraDoc from PDFSharp to render HTML to PDF. LINK:
http://www.pdfsharp.com/[
^]
And now to create the HTML output including server side controls, what u need to do is, put the whole pages codes inside a single user control and follow the link to generate the HTML on runtime which will produce the output html which you need to then feed to the MigraDoc to create the PDF document.
StringBuilder SB = new StringBuilder();
StringWriter SW = new StringWriter(SB);
HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
UCDummy.Visible = true;
UCDummy.RenderControl(htmlTW);
WhereEverIWantItToGo = SB.ToString();
UCDummy.Visible = false;
http://www.velocityreviews.com/forums/t104419-render-and-get-html-from-usercontrol.html[
^]
I have used this technique before, but can't find the code snippet now. Send me an email if u need it, i will have to do some digging.
--------------------------- NEW CODE SAMPLE ---------------------
let say u want to render the whole aspx page and get the output in html string which u can then push it to pdf generator:
System.Text.StringBuilder sb = new StringBuilder();
System.IO.StringWriter tw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter ht = new HtmlTextWriter(tw);
this.RenderControl(ht);
string body = sb.ToString();
just as a tip.. before doing this.. u might want to turn off ur header and footer controls if u don't need them. That is also easy to do, just before calling RenderControl, make those controls visibility to hidden.
The main key here is the this.RenderControl which takes a HtmlTextWriter.
Hope this helps.
Thanks..