Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am using following code to create pdf using itextsharp in asp.net. Its working completely fine..

C#
string attachment = "attachment; filename=" + "abc" + ".pdf";
                    Response.ClearContent();
                    Response.AddHeader("content-disposition", attachment);
                    Response.ContentType = "application/pdf";
                    StringWriter s_tw = new StringWriter();
                    HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
                    h_textw.AddStyleAttribute("font-size", "8pt");
                    h_textw.AddStyleAttribute("color", "Black");
                    divApplicantData.RenderControl(h_textw);
                    Document doc = new Document();
                    doc = new Document(PageSize.A3,5,5,15,5);
                    FontFactory.GetFont("Verdana", 80, iTextSharp.text.BaseColor.RED);
                    PdfWriter.GetInstance(doc, Response.OutputStream);
                    doc.Open();
                    StringReader s_tr = new StringReader(s_tw.ToString());
                    HTMLWorker html_worker = new HTMLWorker(doc);
                    html_worker.Parse(s_tr);
                    doc.Close();
                    Response.Write(doc);
                    Response.End();

How can we give particular folder path so that it will store pdf's to that particular folder.????
Posted
Updated 21-Jul-13 20:04pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900