You can add page numbers to your PDF files as shown in this code:
By using a page number task as a process tool you will add numbers to your PDF pages.
Many settings can be customized with the advanced options explained in next sections.
first_cover is a useful property for books or magazines and allows you to avoid numbering the first page of your document. It is recommended to combine this property with first_cover to set from which number you want to begin your PDF page numbers.
Default: true
starting_number will let you set from which number the page numbering will start and it is recommended to combine this with first_cover and pages to set which pages will be numbered.
Default: 1
pages has plenty of options to be numbered. See them:
Default: all
font_family, font_size and font_color are properties to customize the page numbers font format. The font_family property changes which font will be used, font_size changes the font size, and font_color changes the color of the numbers.
Default: Arial Unicode MS 14px #000000
It is possible to set the page number format and add strings to it concatenated with variables using text. In the code example, the page number content is: "Page N of P" where N is the number of the current page and P is the total number of pages in the PDF document.
Default: N
vertical_position allows you to set the vertical position of page numbers to the top or the bottom of the page. Note that there will not be a margin. In order to do this, use vertical_position_adjustment.
Default: bottom
vertical_position_adjustment applies a displacement of pixels from the standard vertical position. This value can be positive or negative. So watch out, because if you place the number at the bottom of the page with vertical_position and then apply a huge pixel displacement, the page number will be off the page!
Default: 0
horizontal_position allows you to set the horizontal position of page numbers to the left, center or right of the page. Take note that left and right positions will be affected by setting facing_pages as you will see in its description.
Default: center
horizontal_position_adjustment will displace the amount of pixels set in params, from its defined horizontal position. This value can be positive or negative so be careful- If you have your number placed to the right with horizontal_position and horizontal_position_adjustment set to a large positive value, you will place your number outside of the page!
With the facing_pages property you can set your PDF numbering in facing mode, like a book or a magazine. This only takes effect when combined with horizontal_position left or right and will place all page numbers mirrored between pages where left will place numbers to the inside and right to the outside of the page. See the example below for a better understanding:
Default: false