9

I using iTextSharp (V 5.4.2.0) to convert a html page to pdf. But I would like to be able to set a new page.

I've tried this:

<div style="page-break-before:always">&nbsp;</div>

and the tag <newpage />

But it doesn't work. What is the best way, to create a html page, including new page tags (or something) to be able to convert it correctly using iTextSharp?

Kind regards,

Matthijs

user369122
  • 792
  • 3
  • 13
  • 33
  • The HTMLWorker class is deprecated and no longer supported. Instead you are encouraged to use the XMLWorker. http://api.itextpdf.com/itext/com/itextpdf/text/html/simpleparser/HTMLWorker.html – Chris Haas Jun 11 '13 at 13:35
  • ah...too bad :-( ok, if I cannot make a workaround, I'll guess I have to check how XHTML/CSS works with XML Worker... thanks! – user369122 Jun 11 '13 at 13:49
  • XMLWorker seems to do the trick. Thanks! – user369122 Jun 12 '13 at 09:19

3 Answers3

34

Use the iTextSharp XML Worker library and then use this HTML:

<div style="page-break-before:always">&nbsp;</div>
David Silva Smith
  • 11,498
  • 11
  • 67
  • 91
1

A <np /> tag in your HTML inserts a page break in the Document/PDF.

Stefan
  • 11
  • 1
  • Thank you so much!! I don't know what this tag does but it surely works. @Stefan Do you have any documentation regarding this? – OhmnioX Apr 05 '22 at 07:10
0

Use this in C# document.NewPage();