set new page in HTML using iTextSharp HTMLWorker (

2019-06-16 20:18发布

问题:

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

回答1:

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

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


回答2:

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



回答3:

Use this in C# document.NewPage();