'Django, Html: How i can display the (number of page / total pages exist) on a pdf printout rendered

I have to render an HTML template to pdf as a response working with the framework Django and I want to add a footer containing the number of pages in the pdf-printout / total number of pages for example, if I have 2 pages in total, the first page should display to me 1/2, How I can do that please using HTML!

I have tried with this code :

      <footer>
        {%block page_foot%}
        <div style="display: block;margin: 0 auto;text-align: center;">
          page: <pdf:pagenumber />
        </div>
      {%endblock%}
      </footer>

But it displays 0 on the first page.

Thanks in advance



Solution 1:[1]

I recommend wkhtml2pdf which allows converting html to PDF and it has such features as having TOC and page numbering.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohamed ElKalioby