xhtml2pdf: `` and `` causes page number to be printed twice
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.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 20 (2 by maintainers)
to “correct” just put
=> this is the encode space<pdf:pagenumber> of <pdf:pagecount> 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).+11
my test case, “Page 1 of 5”:
code:
<div id="header">Page <pdf:pagenumber> of <pdf:pagecount></div>result:Page 1 of 55code:<div id="header">Page <pdf:pagenumber></div>result:Page 11but there is a solution: code:
<div id="header">Page <pdf:pagenumber> of <pdf:pagecount> </div>result:Page 1 of 5and code:<div id="header">Page <pdf:pagenumber> </div>result:Page 1I was able to fix by adding a new line like
It was stated on the document https://xhtml2pdf.readthedocs.io/en/latest/format_html.html#example-with-2-static-frames-and-1-content-frame
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'>