ihorko ihorko - 5 months ago 61
ASP.NET (C#) Question

iTextPdf how to break page

I generate pdf file from html page using iTextPdf like:

iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
TextReader reader = new StringReader(HTML);

but my html page is large and I need to add page brakes in specific palces.

How can I add these page breaks in pdf?



There is a HTMLWorker.ParseToList. Can't you use that?

  1. Get n elements from ParseToList
  2. Add first x elements to PDF
  3. Call NewPage on PDF
  4. Add remaining elements to PDF