8
Answers

How to insert new page in PDF with itextSharp

Sanket Jain

Sanket Jain

7y
10.6k
1
I have 2 tables in my form. I am generating PDF file with the help of itextsharp.dll
 
I want to break the page when 2nd table is started but it can't work right now
I inserted 2 tables in panel & write following code
 *******************************************************************************************
Response.AddHeader("content-disposition", "attachment;filename=Report.pdf");
Response.ContentType = "application/pdf";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

panelPrint.RenderControl(htmlWrite);

System.IO.StringReader sr = new System.IO.StringReader(stringWrite.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 7f);
//Document pdfDoc = new Document(
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
 
***********************************************************************************************
 
So please tell me how to break that page when 2nd table is started?
 
Answers (8)