ihorko ihorko - 1 year ago 110
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?


Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download