Page Numbers and Page Breaks
using IronPdf;

var html = @"
    <p> Hello Iron</p>
    <p> This is 1st Page </p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 2nd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 3rd Page</p>";

// Instantiate Renderer
var renderer = new ChromePdfRenderer
{
    RenderingOptions =
    {
        HtmlFooter = new HtmlHeaderFooter()
        {

            MaxHeight = 15, // millimeters
            HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
            DrawDividerLine = true
        }
    }
};

var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("pageNumber.pdf");
NuGet Download
PM > Install-Package IronPdf
Page Numbers and Page Breaks

Page Numbers and Page Breaks

IronPDF's flexibility when it comes to editing and rendering headers and footers to the developer's taste and functionality is unmatched. This feature allows us to merge more information about page numbering into the header or footer.

In this example, we will show you how to deal with page numbers and page breaks in IronPDF.

This operates within the two supported header and footer options, which include HtmlHeaderFooter and TextHeaderFooter. It is quite easy to handle either option.

The class TextHeaderFooter defines PDF header and footer display options and uses a logical approach to rendering headers and footers for the most common use cases. You can set page numbers to display on the right, center, or left of the header or footer and also adjust the font type and size to make it consistent with the rest of your PDF body text.

To create a page break in HTML to PDF in .NET, you can use the HTML snippet:

For more details on how to use these features effectively, visit the IronPDF Documentation for Headers and Footers on the official website.

Learn to manage HTML to PDF page breaks with IronPDF.
View on GitHub

Ready to Get Started?

Nuget Downloads 21,916,531Version:2026.11just released