0

How to convert .aspx page with css class design to pdf format which contains asp.net controls.

I have used some code but its not covert the page with proper allignment and design.

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
a.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0.0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

I have used this code..

Can you help me.please.

user3575611
  • 1
  • 1
  • 4
  • I am not sure which third party PDF library you are using but the most popular ASP.NET grid controls on the market offer built-in export to PDF capabilities. Here is an example: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/pdf-export/defaultcs.aspx. – Rumen Jekov Jul 04 '14 at 13:33
  • is pdf conversion from aspx page will be possible with jspdf jquery? if it possible then can you refer me any suggestion – user3575611 Jul 05 '14 at 06:00
  • Yes, you should be able to export a pdf from an aspx page. See these useful posts for more information: http://stackoverflow.com/questions/19786113/export-html-page-to-pdf-on-user-click-using-javascript http://stackoverflow.com/questions/19783721/exporting-web-page-into-pdf-using-jspdf – Rumen Jekov Jul 05 '14 at 18:08

0 Answers0