docbook / xslTNG

DocBook xslTNG Stylesheets
https://xsltng.docbook.org
MIT License
41 stars 20 forks source link

Page number is 0 in PDF TOC when using page-style=book with weasyprint #497

Open fsteimke opened 3 months ago

fsteimke commented 3 months ago

Hi Norm, up to now i used the Antenna House Formatter for rendering HTML paged media (created with print.xsl instead of docbook.xsl) without problems. But i am sure that many users will not (or can not) purchase a commercial product. I am sure that it must be possible to use the xslTNG Stylesheets with some open-source or cost-free products to get PDF output.

I tried weasyprint and the results are very promising. But there is an issue with page numbers in the TOC (and other target-counter (page) references: they give not the real page number, but a 0 (zero) instead. The good news is: this happens only when i set the page-style parameter to book. Page numbers are correct when article is used as page-style. This means that it is possible in principle, and that there mus be an issue with CSS when in book style.

I have made samples with book style and article style and a fresh installation of xslTNG 2.2.0.

sample.zip

Unfortunately i have only little knowledge about CSS, so i will not be able to make a PR for this issue.

Greetings, Frank

liZe commented 3 months ago

Hello!

The bug is caused by:

html.book-style .book .list-of-titles {
  counter-reset: page;
}

I suppose that the bug is in WeasyPrint … but as always with page counters, I’m not sure yet. 😄

As a workaround, you can override this rule with an extra

html.book-style .book .list-of-titles {
  counter-reset: none;
}
ndw commented 3 months ago

See also #433

liZe commented 3 months ago

If you’re interested in solving the bug in WeasyPrint (if there’s a bug!), don’t hesitate to open an issue on WeasyPrint’s repository.