Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<pdf:pagenumber /> is not working anymore with 0.2.9 #670

Open
timobrembeck opened this issue Feb 1, 2023 · 5 comments
Open

<pdf:pagenumber /> is not working anymore with 0.2.9 #670

timobrembeck opened this issue Feb 1, 2023 · 5 comments
Labels
bug Something isn't working regression Something that was working before tags Problems with custom <pdf> tags

Comments

@timobrembeck
Copy link
Collaborator

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

@charludo
Copy link
Contributor

charludo commented Feb 1, 2023

@timoludwig I don´t think itś our stylesheet removing it makes no difference.

@timobrembeck timobrembeck added tags Problems with custom <pdf> tags bug Something isn't working regression Something that was working before labels Feb 1, 2023
@timobrembeck timobrembeck pinned this issue Apr 15, 2023
@stefan6419846
Copy link
Contributor

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 817c901.

@timobrembeck timobrembeck changed the title <pdf:pagecount> is not working anymore with 0.2.9 <pdf:pagenumber /> is not working anymore with 0.2.9 Oct 3, 2023
@timobrembeck
Copy link
Collaborator Author

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.

@mwaterfall
Copy link

mwaterfall commented Oct 28, 2023

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>&#8203;<pdf:pagenumber /></td> <!-- Outputs: <td>&#8203;11</td> -->

Other kinds of whitespace make no difference and the number is still not rendered.

@EKami
Copy link

EKami commented Jan 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something that was working before tags Problems with custom <pdf> tags
Projects
None yet
Development

No branches or pull requests

5 participants