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> and <pdf:pagecount> causes page number to be printed twice #106

Closed
commx opened this issue May 8, 2013 · 20 comments · Fixed by #695
Closed

<pdf:pagenumber> and <pdf:pagecount> causes page number to be printed twice #106

commx opened this issue May 8, 2013 · 20 comments · Fixed by #695
Labels
bug Something isn't working tags Problems with custom <pdf> tags

Comments

@commx
Copy link

commx commented May 8, 2013

I have strange issues with the above tags inside html templates.

Let's say I have <div id="footer_pagenumber">Page <pdf:pagenumber/></div> then the page number is printed twice (11 instead of 1). If I add a single whitespace after the <pdf:pagenumber/> tag, the number is fine. The same problem applies to <pdf:pagecount/>.

Another issue is with <pdf:pagecount/> is that if I use this tag, the background image of my PDF is not rendered anymore.

Tested with xhtml2pdf v0.0.5, reportlab 2.7 and Pillow 2.0.0.

@machineghost
Copy link

+1

@bhosleabhimanyu
Copy link

+1
Is there a easy in which we can accelerate the development of the project?

@tomwalters
Copy link

+1 (or +11)

@felikjunvianto
Copy link

+1, experienced the same thing. Is there any way we can help to fix it?

@maoaiz
Copy link

maoaiz commented Jan 30, 2015

+1 I have the same problem with the pdf:pagecount tag. It's show 11 instead of 1, or 22 instead of 2.

@johnfraney
Copy link

+1. Tested with xhtml2pdf 0.0.6 and reportlab 2.7. The issue occurs with <pdf:pagenumber> also.

@pavlix
Copy link

pavlix commented Jan 27, 2016

I also experience it but I found a workaround. It was good enough to put one space just after the tag, i.e. change --<pdf:pagenumber>-- to --<pdf:pagenumber> -- (double hypen is there to make the space visible).

@w-
Copy link

w- commented Mar 20, 2016

+11

@citizen-stig
Copy link
Contributor

+1

@benjaoming
Copy link
Contributor

benjaoming commented Apr 25, 2016

To anyone bothered by this issue and thinking it's very old, silly and simple, yet no one is solving it, proving that this project is abandoned: NO!

Please feel encouraged to resolve the issue in the develop branch, your improvements shall be noted, merged and released! This project is far from dead, and has had both issues fixed and new features implemented recently. However the community-led idea will only take flight when people step up, and we need that for a 0.1 release to happen within the next months :)

@w-
Copy link

w- commented May 24, 2016

I looked through the code but don't really understand where the issue might be taking place.
I imagine it is probably here, but not sure as I don't understand what is going on
https://github.com/xhtml2pdf/xhtml2pdf/blob/master/xhtml2pdf/xhtml2pdf_reportlab.py#L269

@boevgeny
Copy link

my test case, "Page 1 of 5":

code: <div id="header">Page <pdf:pagenumber> of <pdf:pagecount></div>
result: Page 1 of 55
code: <div id="header">Page <pdf:pagenumber></div>
result: Page 11

but there is a solution:
code: <div id="header">Page <pdf:pagenumber> of <pdf:pagecount> </div>
result: Page 1 of 5
and
code: <div id="header">Page <pdf:pagenumber> </div>
result: Page 1

@alfonso-feria
Copy link

alfonso-feria commented Apr 11, 2019

Un parche que soluciona, pero no es la manera correcta, es ocultar el segundo pdf:pagecount, ya que por lo visto el ultimo se esta repitiendo dando como resultado 1 de N

Página <pdf:pagenumber> de <pdf:pagecount> <pdf:pagecount style='display:none'>

@marioguima
Copy link

marioguima commented Jan 11, 2020

to "correct" just put &nbsp;
&nbsp; => this is the encode space
<pdf:pagenumber> of <pdf:pagecount>&nbsp;

@haruanm
Copy link

haruanm commented Oct 30, 2020

I have the same issues.
The the space after the pagecount does not fix the background issue.
I'm using python 3.8 with xhtml2pdf 0.2.5

@luisza luisza added the tags Problems with custom <pdf> tags label Oct 30, 2020
@CaetanoGS
Copy link

I downgrade the library version and it worked for me.

I was using xhtml2pdf==0.2.5 and now I am using xhtml2pdf==0.2.3

@Dean-Christian-Armada
Copy link

I was able to fix by adding a new line like

<div id="footer_content">(c) - <pdf:pagenumber>
    </div>

It was stated on the document https://xhtml2pdf.readthedocs.io/en/latest/format_html.html#example-with-2-static-frames-and-1-content-frame

  • With a hashtag Developer's note:

@timobrembeck timobrembeck added the bug Something isn't working label Feb 1, 2023
@timobrembeck timobrembeck changed the title pdf:pagenumber and pdf:pagecount tag issues <pdf:pagenumber> and <pdf:pagecount> causes page number to be printed twice Feb 2, 2023
@michal-stachura
Copy link

+1
Adding white space solve problem

@felikjunvianto
Copy link

@luisza thank you for picking up this old issue!

@w-
Copy link

w- commented Jun 25, 2023

unbelievable. i never thought i would see the day.
and for the fix to be so succint.

i no longer use this library but thx @JanEgner

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

Successfully merging a pull request may close this issue.