how div export to pdf in asp.net [Resolved]

Posted by Cpatil1000 under ASP.NET on 5/28/2016 | Points: 10 | Views : 335 | Status : [Member] | Replies : 1
Hi,

i have develop the form. in the form i am showing left side html table
and right side goodle chart. I have found some code online, but only on html
table for pdf file. So you do combine this following code. I want direct create file.pdf name
not with print window and then save.

code.. for html table
====================
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);

StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
employeelistDiv.RenderControl(htmlTextWriter);

StringReader stringReader = new StringReader(stringWriter.ToString());
Document Doc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(Doc);
PdfWriter.GetInstance(Doc, Response.OutputStream);

Doc.Open();
htmlparser.Parse(stringReader);
Doc.Close();
Response.Write(Doc);
Response.End();




Responses

Posted by: A2H on: 5/28/2016 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
This code is working fine on IE 11 and Chrome as it saves the file without showing the print screen preview. on which browser you are facing issue

Thanks,
A2H
My Blog

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response