Table of Contents

Method CurrentPageNumber



Adds the current page number to the current paragraph.

public TextPageNumber CurrentPageNumber(string? sectionName = null)


sectionName string

The optional section name.



The added page number.


When sectionName is null then this method returns the current page number in the document.

When sectionName is not null then this method returns the current page number relative to the first page of the section. For example, a document contains 5 pages with a section on pages 3-4. This method will draw the following values depending on the current page:

  • -1 on the page 1.
  • 0 on the page 2.
  • 1 on the page 3.
  • 2 on the page 4.
  • 3 on the page 5.

The section sectionName may not exist when this method is called. However, the section must exist when the document is rendered. Otherwise, the LayoutException will be thrown during the rendering. Use the Section(string) method to add a section.

This method does not complete the current paragraph. I.e., a next text chunk will be placed in the same paragraph.