I am using iTextSharp to convert html contents inside repeater control to pdf(contents comes from database). everything is OK but every repeated content should come in new pdf page not two repeated data in same page.. for example i am binding student registration information from database to a repeater control and i want to convert the contents to pdf but registration data of two students appears in same pdf page which should not happen. multiple records should come separately in new pages not in same page
code to convert repeater contents to pdf
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Registrations.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Repeater1.RenderControl(hw);
StringWriter sw2 = new StringWriter();
HtmlTextWriter hw1 = new HtmlTextWriter(sw2);
StringReader sr = new StringReader(sw.ToString().Replace("\r", "").Replace("\n\n", "").Replace(" ", ""));
Document pdfDoc = new Document(iTextSharp.text.PageSize.A4, 40f, 40f, 100f, 95f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.NewPage();
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();