Trouble coding pagination for PDFs

I am trying to to add pagination to my project using the latest version of the Apryse node js sdk. I am trying to post process (stamp custom pdf pages using Apryse stamper class) my pdfs with custom headers and footers after rendering out the full pdf. I have a custom text placeholder called “[PAGE_NUMBER]” that I use the replacer on, but the replacer replaces all instaces of the placeholder with the same exact page nuber no matter what, my pdf is at least 5-20 pages long and the page number is replaced to 1 on every single page even though I iterate through the pages and process the placeholder on every page.

Example code:

for (itr; await itr.hasNext(); itr.next()) {
  const curritr = await itr.current();
  const pagenumber = await curritr.getIndex();

// use replacer.add string [PAGE_NUMBER] to pagenumber
}

Hi Tyler,

It’s probably better to use our stamper class or page labels if you want to add page numbers:

If you’re still having troubles, please upload a sample input and output file as well as your full code snippet.