PDF Template total pages {nb} code not working

Hello

I am trying to display the total number of pages in the footer of each page in a PDF template.

From a similar thread asking about how this can be done (can’t include link as I can only have a max of two links in the post sorry), I learnt that SuiteCRM uses mPDF for the PDF Templates, and therefore this can be achieved with mPDF replacable aliases, like found here: Replaceable Aliases – What Else Can I Do – mPDF Manual

Based on that documentation, I have put the following into the footer: “Page {PAGENO} of {nb}”

The {PAGENO} tag works perfectly, and changes based on what page it is for. The {nb} tag does not work at all, and stays as {nb} rather than changing to the total pages (or anything else)

Another thread indicates that {nb} should work, and has worked since 2014: Fields for PDF templates

Things I have tried:

  • Putting the tag in other parts of the PDF template to see if it comes through there (such as in the header, body etc). This does not work
  • Using other tags on the page such as {nbpg} - this stays the same and does not change into anything
  • Removing the {PAGENO} code and only using {nb}. Nothing
  • Using all capital letters, {NB}. Nothing

I’m not sure what to try next to get this working - can anyone help?

Assuming it is not a SuiteCRM issue, could it be something to do with PHP settings or extensions? Or is it more likely to be a SuiteCRM issue, or User (me) issue?

I am running SuiteCRM v7.12.6

Cheers

Edit: The mPDF documentation says that {nb} only works when in a header or footer, and not in the main text. The {nb} code I have is in the footer field of the PDF template. But perhaps mPDF is not recognising this as the footer? Despite it appearing on every page and {PAGENO} works fine.
Just trying to think of all possible reasons…

The mPDF engine had to be replaced with TCPDF for reasons related to licenses.

I’m not sure which version this changed happened, but you can check the release notes to find out.

Try looking at TCPDF documentation and see what codes you can use.

1 Like

For others looking for this info: you can use {:ptp:} to replace {np}
Also {:pnp:} can be used to replace {PAGENO}

2 Likes

This is the correct answer - thank you! I tried to find the code for TCPDF after pgrs comment above but could not find anything. I tried this and it is correct, cheers