xhtml2pdf
xhtml2pdf copied to clipboard
`<pdf:pagenumber />` is not working anymore with 0.2.9
Interestingly, the page counter <pdf:pagenumber/>
in the footer did work for me in previous versions including 0.2.8
(so I couldn't reproduce #618 or #654), but with the new version 0.2.9
released, they don't work anymore.
The part in the footer where the number is supposed to be is just empty.
Could this also be related to some custom styles in my style sheet?
Not sure how to provide a minimal example to reproduce the problem, are there already some test cases related to page numbers which can be adapted to cover more use cases?
As for a non-minimal example, see e.g. this test page:
With xhtml2pdf version 0.2.8
(current develop
branch - page numbers are working):
https://github.com/digitalfabrik/integreat-cms/blob/7393f06527f0e5f6538ea8eeb2d97ac90aa0c6e0/tests/pdf/files/e155c5e38b/Integreat%20-%20Englisch%20-%20Welcome.pdf
With xhtml2pdf version 0.2.9
(current update/xhtml2pdf
branch - page numbers are not working):
https://github.com/digitalfabrik/integreat-cms/blob/bc9d0ca1787fe582f8ddc0bcfdb0a80de6dadcc2/tests/pdf/files/e155c5e38b/Integreat%20-%20Englisch%20-%20Welcome.pdf
@timoludwig I don´t think itś our stylesheet removing it makes no difference.
What is the actual issue about: <pdf:pagecount>
(as in the title) or <pdf:pagenumber/>
(as in the text)`? Are you able to provide some isolated standalone code for reproduction which does not require a complete Django setup and skimming through multiple of your source files?
Apparently, https://xhtml2pdf.readthedocs.io/en/latest/format_html.html#example-with-2-static-frames-and-1-content-frame is not affected - at least it gives me the correct values.
By the way: The corresponding commit might be https://github.com/xhtml2pdf/xhtml2pdf/commit/817c901362a824a0deaf418a40c86bfccf860e83.
Sorry for the confusion, it was <pdf:pagenumber />
.
Unfortunately I don't have time to dig deeper at the moment, I'll revisit this in November.
I can also reproduce this issue, and here's my observations.
It looks like it was potentially introduced here: "Support add pagenumber and page count as simple text"
I've noticed that whilst you can have page numbers "inline" as of 0.2.9, it seems to have broken the page number tag when it's the only child element:
This no longer works:
<td><pdf:pagenumber /></td> <!-- Outputs: <td></td> -->
However when you introduce some text either side of the tag, with whitespace around the tag, the page number is now rendered (along with the additional text).
<td>TEST <pdf:pagenumber /></td> <!-- Outputs: <td>TEST 1</td> -->
If you introduce text either side of the tag without whitespace around the tag, the page number is rendered twice!
<td>TEST<pdf:pagenumber /></td> <!-- Outputs: <td>TEST11</td> -->
I tested a workaround with a zero-width space, however that appeared to cause the page number to be rendered twice too.
<td>​<pdf:pagenumber /></td> <!-- Outputs: <td>​11</td> -->
Other kinds of whitespace make no difference and the number is still not rendered.
As of version 0.2.13, using <pagecount>
anywhere in the footer will make it disappear, using the tricks (with whitespaces) shown above by @mwaterfall will restore the footer