@jan_blaha This will not work if we have configured header & footer in our template.
$pdf.pages[$pdf.pages.length - 1].text
will always have text in it. How can we handle this scenario?
Also .removePages() is not adjusting the total pages count. If we have 2 pages and the 2nd page is blank, after using .removePages() the 1st page still shows '1 out of 2' pages. How to adjust that too?