htmlpdfweasyprint

WeasyPrint is print wrong page number using keywords?


I am using the WeasyPrint library to print page numbers at the bottom of a PDF. The syntax is as follows within the @page element in HTML:

    @bottom-center {
        counter-increment: page;
        content: "Page " counter(page) " of " counter(pages);
        margin: 10px 10px 25px 10px;
    }

Previously this worked and would print "Page 1 of 1" for 1-page documents. Recently it's printing "Page 2 of 1" without changing any code.

For documents that are actually two pages long, I get "Page 2 of 2", and then "Page 3 of 2".

I am using version 44 of WeasyPrint.

Why is it printing the wrong page number here?


Solution

  • The line with

    counter-increment: page; 
    

    Was not supposed to be there. Opened an issue on the WeasyPrint GitHub page and was told not to modify the page variable unless we want it to be different.